vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Is dotnet_style_parentheses_* supported?

Open marcospgp opened this issue 3 years ago • 2 comments

I can't seem to get it to work with Omnisharp in VSCode.

My .editorconfig file is working, as I can disable rules normally. The lines

dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity

however, seem to not have any effect.

Is setting these values supported?

marcospgp avatar Aug 26 '22 21:08 marcospgp

Code style rules require omnisharp.enableRoslynAnalyzers be enabled. To change the severity of these analyzers you would need to also configure IDE0047 & IDE0048. See the docs.

Example making them warnings:

root = true

[*.{cs,vb}]
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity

dotnet_diagnostic.IDE0047.severity = warning
dotnet_diagnostic.IDE0048.severity = warning

JoeRobich avatar Aug 26 '22 21:08 JoeRobich

Thanks for the quick response @JoeRobich !

I did double check the things you mentioned and could not find any issue, yet the dotnet_style options are still not working for me :(

My .editorconfig file is here for reference.

I did try both including the :warning suffix (as in always_for_clarity:warning) and not. Neither seems to work.

Enabling IDE0047 and IDE0048 specifically should not be necessary as I have enabled all rules by default, and I do get the warning from IDE0047 when I do use parenthesis for clarity (such as in (a / b) * (c + d)).

marcospgp avatar Aug 26 '22 22:08 marcospgp