Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio code style preference csharp_prefer_braces not working

In Visual Studio 2017 I go to Tools > Options > Text Editor > C# > Code Style, and toggle the option "Prefer braces" from yes to no and back.

It does nothing. The preview below the options always has braces regardless of the setting.

Even an explicit .editorconfig file on csharp_prefer_braces = false:none does not change the behavior.

Is this a bug? Or is some other option overriding?

like image 443
Ron Newcomb Avatar asked Apr 23 '26 13:04

Ron Newcomb


1 Answers

The property after the ":" will decide how this is treated in VS Code. So using none will mean that VSCode doesn't actually enforce this.

The MS docs here describe "none" as:

"None": Do not show anything to the user when this rule is violated. Code generation features generate code in this style, however. Rules with none severity never appear in the Quick Actions and Refactorings menu. In most cases, this is considered "disabled" or "ignored".

Perhaps you could try using csharp_prefer_braces = false:error instead?

like image 179
WheretheresaWill Avatar answered Apr 27 '26 13:04

WheretheresaWill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!