Namespace Imports' "Cleanup" link should also sort/reorder namespaces (and weird sort rules?)
Currently the "Cleanup..." link[1] removes invalid and missing namespaces, but it doesn't re-order or sort the namespace list, which was my expectation given how Visual Studio's own "Remove and Sort Usings" action does the same (and passes the Ronseal challenge to-boot).
When invoked, the "Cleanup" command should...
- Remove missing namespaces (as it currently does)
- Remove empty or invalid lines
- Lexicographically (case-insensitive) sort namespaces...
- ...except the
System.*
namespaces should be sorted first.
Requested UI changes:
- Change "Cleanup..." from a link to a button.
- I feel it should be a button, not a hyperlink. Links are intended to indicate to the user that clicking it will open a WWW link in a browser, not an application dialog.
- Or perhaps use a split-button, with "Remove missing namespaces" and "Sort namespaces" as child menu options?
- Change "Pick from assemblies..." to a toggle-button (perhaps using the pushpin icon?).~~
UPDATE:
Hmm, this is weird - after playing around with the Namespace Imports editor, it seems to automatically sort namespaces when the dialog is closed, but it has some weird sorting rules that cause some (but not all) System.*
namespaces to be sorted first - so I'm not sure what's going on there.
UPDATE2
Okay, so I see that I thought it wasn't sorting namespaces at all because it kept on having some of the System.*
namespaces sorted after other library namespaces (e.g. Azure.*
or Microsoft.Win32
), like so:
Comments
LINQPad always sorts the namespaces after you close the dialog, regardless of whether you click 'Cleanup'.
'Cleanup' is just to remove bad namespaces.
In terms of sorting, LINQPad puts the default namespaces first, followed by user-added namespaces. This makes it easy to identify what you've added.