dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.89k stars 4.01k forks source link

Opening .editorconfig in VS 17.2 Preview 2 causes conflicting unsaved changes #60396

Open tannergooding opened 2 years ago

tannergooding commented 2 years ago

Version Used: VS 17.2 Preview 2

Steps to Reproduce:

  1. Clone https://github.com/terrafx/terrafx
  2. Open the solution in VS 17.2 Preview 2
  3. Open the .root/.editorconfig file
  4. Note that it shows pending changes

Expected Behavior:

There should be no pending changes or pending changes should be purely additive/whitespace fixes

Actual Behavior:

There are a couple of whitespace changes (acceptable) and then a set of pending changes which effectively duplicate existing defines that exist further up.

In the case of TerraFX, the following are additional changes appended to the end of the file. Note that dotnet_style_* are all duplicates. dotnet_naming_* are new and in some cases conflict with existing naming rules TerraFX defines itself.

[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers = 

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers = 

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers = 

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix = 
dotnet_naming_style.begins_with_i.word_separator = 
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix = 
dotnet_naming_style.pascal_case.required_suffix = 
dotnet_naming_style.pascal_case.word_separator = 
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix = 
dotnet_naming_style.pascal_case.required_suffix = 
dotnet_naming_style.pascal_case.word_separator = 
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_coalesce_expression = true:error
dotnet_style_null_propagation = true:error
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
dotnet_style_prefer_auto_properties = false:error
dotnet_style_object_initializer = true:error
dotnet_style_collection_initializer = true:error
dotnet_style_prefer_simplified_boolean_expressions = true:error
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_explicit_tuple_names = true:error
dotnet_style_prefer_inferred_tuple_names = true:error
dotnet_style_prefer_inferred_anonymous_type_member_names = true:error
BhaaLseN commented 2 years ago

I wonder if this is related, but: I just copied over an .editorconfig (that I made a while back) into a new project and opened it with the EditorConfig UI (on VS 2022 17.2.3), with the intent of getting new settings inserted so I can look at whats new.

What happened was that it insert those:

dotnet_prefer_inferred_tuple_names = true:suggestion
dotnet_prefer_inferred_anonymous_type_member_names = true:suggestion

...while I already had those in the file:

dotnet_style_prefer_inferred_tuple_names = true : suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true : suggestion

Difference being the _style in between (dotnet_style_prefer vs. just dotnet_prefer)

I've also found MicrosoftDocs/visualstudio-docs#634 while trying to figure out which one was the correct one; but after getting inconclusive and even conflicting results (mostly from the official docs for IDE0037), I just left them both in (for now).