Skip to content

Global System using directives should be sorted first #1003

@vipentti

Description

@vipentti

First of all, great project and big fan of automating formatting.

I noticed an inconsistency when it comes to sorting regular using System* directives vs global using System* directives:

When sorting the regular using directives the System using directives are ordered before the non-system using directives.

However when sorting global using all the directives are grouped together and sorted as one set.

Basically sorting the following:

using Library;
using System;
using AnotherLibrary;

Results in

using System;
using AnotherLibrary;
using Library;

Where as sorting the following:

global using Library;
global using System;
global using AnotherLibrary;

Results in

global using AnotherLibrary;
global using Library;
global using System;

My suggestion would be to use the same pattern with global System using directives so that they would be sorted before other non-System global using directives.

I don't mind doing the work if this sounds like a reasonable idea.

yield return globalUsings.OrderBy(o => o.Using, Comparer).ToList();
yield return globalAliasUsings.OrderBy(o => o.Using, Comparer).ToList();
yield return systemUsings.OrderBy(o => o.Using, Comparer).ToList();
yield return aliasNameUsings.OrderBy(o => o.Using, Comparer).ToList();
yield return regularUsings.OrderBy(o => o.Using, Comparer).ToList();
yield return staticUsings.OrderBy(o => o.Using, Comparer).ToList();
yield return aliasUsings.OrderBy(o => o.Using, Comparer).ToList();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions