This is a analyzer and code fix provider for C# that moves usings from the file they are used to a file called Usings.cs.
$ dotnet add package MoveToGlobalUsingsAnalyzerThis is a analyzer and code fix provider for C# that moves usings from the file they are used to a file called Usings.cs.
Move to Global Usings

Support for .editorconfig - severity and file name
CodeFix CS0246

Global usings are automatically sorted
Sort - global usings with alias are always last. The alias is not considered when sorting.
Example:
global using ZNamespace;
global using MyService = ANamespace.MyService;
The GlobalUsingsAnalyzerCodeFixProvider class is responsible for providing the code fix. It contains the following methods:
The code fix is implemented in the ReplaceUsingWithGlobalAsync method, which takes the document, the using directive syntax node, and a cancellation token as parameters. It first removes the using directive from the original file and adds it to the Usings.cs file, creating the file if it does not exist. It then returns the updated solution.
The GlobalUsingsFixAllProvider is the class that handle the Fix All button.
The CodeFixResources is a class that contains the title of the code fix action.