csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Consider honoring dotnet_sort_system_directives_first

Open ramarivera opened this issue 9 months ago • 1 comments

Is there any possibility to consider honoring dotnet_sort_system_directives_first=false from editorconfig? It almost sounds like a joke, but its the one setting where I am getting pushback on enabling Csharpier on our org repos :( If it is not possible, could you at least explain the rationale for that, so that I have more context when explaining how it is a small con when compared to all of Csharpier pros?

Thanks!

ramarivera avatar Mar 30 '25 13:03 ramarivera

CSharpier is strict about not adding new settings, but I'm hoping you can convince your org because this does seem pretty minor.

As to why CSharpier sorts them with usings first

  • dotnet_sort_system_directives_first = true is the default option, which is how CSharpier sorts usings.
  • Of the code I've checked in https://github.com/belav/csharpier-repos - it all seems to sort system directives first. That includes
    • Roslyn
    • AspnetCore
    • EFCore
    • Automapper
    • dotnet Runtime

And with the ability to auto add usings in major IDEs I don't know how often you'll even be looking at the usings.

  • Rider collapses them by default
  • VS has the option to collapse them when opening a file

belav avatar Mar 30 '25 15:03 belav

@belav What I don't understand is, why it's mentioned in the docs, when setting it to false will do nothing.

BFS-JWesseler avatar Nov 18 '25 13:11 BFS-JWesseler

@BFS-JWesseler it appears under this heading because it works the way that setting will, but is not configurable.

# Non-configurable behaviors
dotnet_sort_system_directives_first=true

belav avatar Nov 18 '25 13:11 belav