codecadwallader / codemaid

CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
http://www.codemaid.net
GNU Lesser General Public License v3.0
1.89k stars 356 forks source link

Incorrect modifier sort order leads to (worst case) compile error #916

Open HugoRoss opened 2 years ago

HugoRoss commented 2 years ago

Environment

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

codecadwallader commented 2 years ago

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.

lolodi commented 1 year ago

Is there a way to disable modifiers re-ordering while this get fixed?

perahoky commented 5 months ago

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.

image image