Existing rule:
Order and group namespaces according to the company (AV2402)
Microsoft namespaces are first. Then any other namespaces in alphabetic order.
New language features to consider:
- using static
This enables to import a class name into scope.
- namespace aliasing (not new, but missing)
Resharper default settings move regular namespace imports to the top, but leaves using static and using aliases unaffected. Example:
using System;
using System.Threading.Tasks;
using Custom;
using SystemConsole = System.Console;
using static Custom.Z;
using CustomX = Custom.X;
using static System.Math;
namespace ConsoleAppNewLang
{
internal class Program
{
public static async Task<int> Main(string[] args)
{
var max = Max(1, 2);
SystemConsole.WriteLine(max);
return await GetAsync(new CustomX());
}
private static Task<int> GetAsync(CustomX x)
{
var y = new Y();
var s = S;
throw new NotImplementedException();
}
}
}
namespace Custom
{
public class X
{
}
public class Y
{
}
public static class Z
{
public static string S;
}
}
This does not help much to come up with a scheme.
Proposal: (with alphabetic ordering inside each group):
- System namespace imports
- Other namespace imports
- Static namespace imports (system first)
- Namespace alias declarations (system first)
This would require the next order for the example above:
using System;
using System.Threading.Tasks;
using Custom;
using static System.Math;
using static Custom.Z;
using SystemConsole = System.Console;
using CustomX = Custom.X;
Existing rule:
Order and group namespaces according to the company (AV2402)Microsoft namespaces are first. Then any other namespaces in alphabetic order.New language features to consider:
This enables to import a class name into scope.
Resharper default settings move regular namespace imports to the top, but leaves
using staticandusing aliasesunaffected. Example:This does not help much to come up with a scheme.
Proposal: (with alphabetic ordering inside each group):
This would require the next order for the example above: