-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding empty lines between groups of using statements, or respect existing empty lines. #988
Comments
I'd be happy if it worked like this:
|
Or, perhaps,
|
Personally, I'm a fan of the following import groups separated by one empty line each:
I'm not sure if there's a precedent for this in how existing C# code bases are formatted but this is similar to how import sorting works in Python formatters such as isort or ruff. To extend this to all the supported types of // global usings at the top since they affect every source file
// split in groups in the same way as non-global imports
global using System.Timers;
global using static System.Math;
global using NonSystemA;
global using NonSystemB;
global using MyProject.Utils;
// System imports - sorted within specific `using` syntaxes
using System.Collections;
using System.Timers;
using static System.Console;
using static System.Math;
using NameB = System.Collections.Dictionary; // sort by import name vs alias name - up for debate
using NameA = System.Collections.List;
// Non-System imports, same rules as above
using NonSystemA;
using NonSystemB;
using static NonSystemA.X;
using static NonSystemB.Y;
using NonSystemAlias = NonSystem.SomeClass;
// Same-namespace imports
using MyProject.ViewModel;
using static MyProject.Collections.Generic;
#if DEBUG // finally any usings in #if's
// use the same heuristics as outside (or continue not sorting as is the case with the released version)
#endif
namespace MyProject.View; // or namespace MyProject.View { ... }
// actual code |
The initial version of sorting usings (#661) did not retain existing empty lines.
If we try to retain existing empty lines then
If we add empty lines automatically
The text was updated successfully, but these errors were encountered: