roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

Proposal: Add analyzer that sorts usings alphabethically

Open MovGP0 opened this issue 7 years ago • 3 comments

there should be an analyzer that sorts usings alphabethically.

Optional: usings for System.* and Microsoft.* namespaces should come before others.

MovGP0 avatar Nov 30 '17 11:11 MovGP0

@JosefPihrt is this something that might make a good community pull request?

edwinf avatar Feb 22 '20 01:02 edwinf

For your information, Visual Studio already does this, out of the box:

image

This will also remove unused usings, but if you don't like that, you can also trigger the sorting as a dedicated action, without the removal (underneath Edit > IntelliSense > Sort Usings).

This will also sort System namespaces on top (by default, I think), controllable by an option. This can also be configured using .editorconfig options, and applied via Code Cleanup.

@MovGP0 Is this of use to you? You mentioned specifically an analyzer in this project, so if you're really looking for something like that, then @JosefPihrt is going to be authoritative on that, otherwise these options might be of use to you ;)

tiesmaster avatar Feb 24 '20 12:02 tiesmaster

I agree that this feature is already available as a part of "code cleanup".

It could be provided as a Roslynator analyzer but it would need to load options from Visual Studio options and .editorconfig options which is not an easy task.

josefpihrt avatar Feb 24 '20 15:02 josefpihrt