codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

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

Open HugoRoss opened this issue 4 years ago • 3 comments

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 .editorconfig travelling up the directories should be respected.
  • Alternatively, the modifier sort order can be configured in CodeMaid's options (per solution or user).

HugoRoss avatar Apr 01 '22 10:04 HugoRoss

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.

codecadwallader avatar Apr 12 '22 12:04 codecadwallader

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

lolodi avatar Aug 14 '23 21:08 lolodi

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

perahoky avatar Apr 05 '24 10:04 perahoky