You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We return directly from the case/default.
Because of using var C# forces us to use the braces around the whole case-statement. Omitting the braces results in the error "CS8647 A using variable cannot be used directly within a switch section (consider using braces)." However, the rule "RCS1031- Remove unnecessary braces" is showing on those braces.
We have work-around for this, like not do a return but a break (which is just below the closing-brace). The working example (which does not show the RCS1031 rule) would be:
Based on code in our application, I have created the following example:
The following things happen in this example:
using var ..
.return
directly from the case/default.Because of
using var
C# forces us to use the braces around the whole case-statement. Omitting the braces results in the error "CS8647 A using variable cannot be used directly within a switch section (consider using braces)." However, the rule "RCS1031- Remove unnecessary braces" is showing on those braces.We have work-around for this, like not do a
return
but abreak
(which is just below the closing-brace). The working example (which does not show the RCS1031 rule) would be:For me this is a real edge-case and frankly I quickly rewrote this to not do the
return
inside the switch. So see if you want/can to fix this.The text was updated successfully, but these errors were encountered: