ReSharper 2022.2 Help

Inline Global Using refactoring

This refactoring allows you to replace one or more global using directives with local using directives in all files where symbols from the corresponding namespaces are used.

In the example below, we apply this refactoring to global using System.Collections; in file GlobalUsings.cs and as a result it adds the corresponding local using directives in files One.cs and Two.cs.

// GlobalUsings.cs global using System.Linq; global using System.Threading.Tasks; global using System.Collections; // One.cs class One { void Test(ArrayList list) { // do something } } // Two.cs using System.Xml; class Two { void Test(ArrayList list, XmlReader reader) { // do something } }
// GlobalUsings.cs global using System.Linq; global using System.Threading.Tasks; // One.cs using System.Collections; class One { void Test(ArrayList list) { // do something } } // Two.cs using System.Collections; using System.Xml; class Two { void Test(ArrayList list, XmlReader reader) { // do something } }

Inline a global using

  1. Set the caret at a global using directive or select multiple global using directives.

  2. Do one of the following:

    • Press Control+Shift+R and then choose Inline Global Using.

    • Right-click and choose Refactor | Inline Global Using from the context menu.

    • Choose ReSharper | Refactor | Inline | Inline Global Using… from the main menu.

  3. ReSharper will add local using directives for selected namespaces to all files in the project where symbols from these namespaces are used, and remove the original global using directives.

This feature is supported in the following languages and technologies:

Language: C#

Language: VB.NET

Language: C++

Language: HTML

Language: ASP.NET

Language: Razor

Language: JavaScript

Language: TypeScript

Language: CSS

Language: XML

Language: XAML

Language: Resx

Language: Build Scripts

Language: Protobuf

Language: JSON

Feature is available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in HTML

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in JavaScript

Feature is not available in TypeScript

Feature is not available in CSS

Feature is not available in XML

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

Feature is not available in Protobuf

Feature is not available in JSON

Last modified: 01 April 2022