Incorrect modifier sort order leads to (worst case) compile error
Environment
- Visual Studio version: 2019 Enterprise
- CodeMaid version: 12.0
- Code language: C#
Description / Steps to recreate / Current behavior
I experience the following issue:
I have a class that defines a property like this:
public static new object SomeProperty => throw new NotImplementedException();
and an .editorconfig that defines the modifier sort order like this (which is nothing fancy - I think it is the recommended default sort order):
[*.cs]
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:error
Now CodeMaid reorganizes it to
public new static object SomeProperty => throw new NotImplementedException();
and I get a compile error (because of my strict definition of rule violations as errors in .editorconfig).
Expected behavior
- Ideally, any modifier sort order that is specified in any
.editorconfigtravelling up the directories should be respected. - Alternatively, the modifier sort order can be configured in CodeMaid's options (per solution or user).
Thanks for reporting the issue. I believe this may be related to a breaking change in the underlying SDK that occurred with the launch of VS2022 (and affected VS2019 as well). There's more information on #879 including a link back to Roslyn where the SDK bug was reported.
Is there a way to disable modifiers re-ordering while this get fixed?
Hello,
we have the same problem. the IDE integrated cleanup mechanism (which is the correct one) sorts members differently than codemaid. So codemaid sorting is wrong and to be fixed please. Or at least give us an option to setup or disable the modifier sorting. Anyways, any cleanup mechanism of codemaid should be configurable.