-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when_multiline on csharp_prefer_braces not working #40912
Comments
as a note, if this rule enforce just to put braces for expressions broken in multiple lines, I don't find this rule useful, we'd need a rule like basically I'd like to use
because I find always risky to put blocks without braces, so I only want to use them when I not inline them togheter like in the example. anyway the editorconfig is blaming so something doesn't work as expected to me. |
This is a duplicate of madskristensen/EditorConfigLanguage#78.
This is not currently supported, but you could write a custom analyzer for this. In addition to the support provided by the IDE analyzer, StyleCop Analyzers provides its own implementation of brace requirements. While neither of these supports the specific style you requested, you can use them as an example to create a new analyzer that handles your specific case. |
thanks for the link. |
I haven't seen another request for the specific combination you were looking for. The |
I second @MithrilMan's opinion. This rule would be far more useful if it also enforced braces on anything that's not inline. The documentation for
I was surprised to find if (true)
Console.WriteLine("Hello World!"); I assume whether you consider the |
The |
It still seems like you have to use this (soon #43051 (comment)) deprecated syntax to configure the option csharp_prefer_braces = when_multiline:suggestion
dotnet_diagnostic.IDE0011.severity = warning
# or just "csharp_prefer_braces = when_multiline:warning"... If using (the preferred syntax) csharp_prefer_braces = when_multiline
dotnet_diagnostic.IDE0011.severity = warning The version : sdk-5.0.102 built-in analyzers |
Version Used:
Visual Studio 16.4.2 Enterprise
Steps to Reproduce:
add in .editorconfig the line
csharp_prefer_braces = when_multiline : error
Expected Behavior:
shouldn't report the warning below and should work in the IDE
Actual Behavior:
The text was updated successfully, but these errors were encountered: