JetBrains Rider 2024.3 Help

Convert to Non-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 } }

Convert to a non-global using

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

  2. Do one of the following:

    • Press Ctrl+Alt+Shift+T and then choose Convert to Non-Global Using.

    • Choose Refactor | Convert to Non-Global Using from the main menu.

  3. JetBrains Rider 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.

Last modified: 23 September 2024