-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Determine the necessary editorconfig to allow enabling IDE0055 #781
Comments
This is what I've come up with so far. I'm still looking to see if there are non- I can't yet figure out if there's any way to control alignment via EditorConfig. ### CSharpier-compatible settings ###
# C# formatting settings - New-line options
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options#new-line-options
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_open_brace = all
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_between_query_expression_clauses = true
# C# formatting settings - Indentation options
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options#indentation-options
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = no_change
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = false
# C# formatting settings - Spacing options
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options#spacing-options
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_parentheses = none
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_after_comma = true
csharp_space_before_comma = false
csharp_space_after_dot = false
csharp_space_before_dot = false
csharp_space_after_semicolon_in_for_statement = true
csharp_space_before_semicolon_in_for_statement = false
csharp_space_around_declaration_statements = false
csharp_space_before_open_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_square_brackets = false
# C# formatting settings - Wrap options
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options#wrap-options
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false
# undocumented
dotnet_style_operator_placement_when_wrapping = beginning_of_line |
Also, these seem to be the only (documented) dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false |
There are also some experimental settings that may be applicable that Visual Studio seems to know about (at least in the preview version, I haven't checked the RTM version yet) that I have yet to investigate since they're undocumented. |
Thanks for digging into this. I tested it out on a large repo and ran into a couple things. With It is unhappy with braces being on the same line as a public void Method(
string someLongName
) { }
if (ex is HttpRequestException) { }
// this is fine
public void Method() { } Switching to It is also unhappy with this statement return from prp in this.DataProvider.LinqQuery<ProductRelatedProduct>()
join p in this.GetTable() on prp.RelatedProductId equals p.Id
where
prp.ProductId == productId
&& prp.SystemListValue.Name == type
&& p.ActivateOn < DateTimeProvider.Current.Now
&& (p.DeactivateOn ?? DateTimeOffset.MaxValue) > DateTimeProvider.Current.Now
select p;
// it wants
return from prp in this.DataProvider.LinqQuery<ProductRelatedProduct>()
join p in this.GetTable() on prp.RelatedProductId equals p.Id
where
prp.ProductId == productId
&& prp.SystemListValue.Name == type
&& p.ActivateOn < DateTimeProvider.Current.Now
&& (p.DeactivateOn ?? DateTimeOffset.MaxValue) > DateTimeProvider.Current.Now
select p; I didn't see any way to disable or ignore either of these. And I'm not sure if we want to make the changes to get IDE0055 happy, but if #661 is implemented, and also puts |
Would love to see this, |
The goal of this ticket is not for CSharpier to support After looking at this again I don't know how useful it is to enable |
The rules under C# Formatting Options appear to all be unnecessary when using CSharpier and can cause conflicts.
The rules under .NET Formatting Options could still be useful.
It would be useful to determine what set of
.editorconfig
options would allow enablingIDE0055
, or provide alternatives for the .NET Formatting OptionsThe text was updated successfully, but these errors were encountered: