Extract Global Using refactoring
This refactoring allows you to convert one or more local
using directives into global using directives and move them to a new or existing file.
In the example below, we apply this refactoring to
using System.Collections; in file One.cs and place the extracted using to GlobalUsings.cs.
Extract a global using
Set the caret at a
usingdirective or select multiple directives.
Do one of the following:
Press Control+Shift+R and then choose Extract Global Using
Right-click and choose Refactor | Extract Global Using in the context menu.
Choosein the main menu.
The Extract Global Using dialog will open.
Specify where the global using should be moved — this could be any existing .cs file in the current project or a new .cs file.
To apply the refactoring, click Next.
ReSharper will remove the
usingdirectives for the selected namespaces from all files in the project (because a local using becomes redundant as soon as a global using appears for the same namespace) and add these directives as
global usingdirectives to the specified file.
This feature is supported in the following languages and technologies: