A Visual Studio Code extension to refactor using statements in your C# projects. Move all top-level using statements to a GlobalUsings.cs file for a simplified and modern C# project structure.
Features
Right-click on .cs file:
Move all using statements before the namespace declaration from the selected file into GlobalUsings.cs in the project root. Removes those using statements from the file.
Right-click on .csproj file:
Recursively scans all .cs files in the project folder (excluding bin, obj, .vs), moves all top-level using statements to GlobalUsings.cs in the project root, and removes them from the individual files.
Right-click on .sln (solution) file:
Parses the solution file for all referenced .csproj projects, applies the project-level logic to each project: all using statements are moved to their respective GlobalUsings.cs files.
Prevents duplicate global using statements in the generated GlobalUsings.cs.
Available via context menu:
Easily access the command by right-clicking .cs, .csproj, or .sln files in the Explorer sidebar.
How to Use
Install the extension from the VS Code Marketplace.
In the Explorer sidebar, right-click a .cs, .csproj, or .sln file.
Select "Move Usings to GlobalUsings.cs" from the context menu.
The extension will refactor your code and display a notification when complete.
Contributing
We welcome contributions!
Fork the repository and clone it locally.
Open the project in VS Code, and use the built-in debugger to run and test the extension.
Create a pull request detailing your changes and improvements.