roslynator
roslynator copied to clipboard
RCS1031: False positive when local variables share names
Product and Version Used:
Roslynator 2019 VS Extension, v3.2.0
Steps to Reproduce:
var key = "key_1";
var value = "false";
switch (key)
{
case "key_1":
{
bool.TryParse(value, out var val);
break;
}
case "key_2":
{
bool.TryParse(value, out var val);
break;
}
// ...
}
Actual Behavior:
RCS1031: Remove unnecessary braces
.
Applying the suggestion raises CS0136.
Expected Behavior:
No warning raised, since the braces cannot be removed without producing the compiler error due to out var val
used in both switch sections.