Back to Devexpress

Optimize Namespace References

coderushforroslyn-115640-refactoring-assistance-optimize-namespace-references.md

latest1.4 KB
Original Source

Optimize Namespace References

  • Aug 03, 2020
  • 2 minutes to read

Purpose

Removes unused references in the “using” (C#) or “Imports” (Visual Basic) section and optionally sorts them in the active source file.

Note

You can also run the Optimize Namespace References refactoring in XAML to remove unused xmlns references. This refactoring does not support reference sorting in XAML.

Availability

Available when the cursor is in a using ( Imports ) statement if the source code file contains unused references.

Usage

  1. Open the Editor | All Languages | Namespace References options page to configure this refactoring. For example, set the “Sort namespace references” option to “Alphabetically”.

  2. Place the caret in a using ( Imports ) statement.

  3. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.

  4. Select Optimize Namespace References from the menu.

After execution, this refactoring sorts the namespace references alphabetically and removes unused references except System and System.Linq.

See Also

Sort Namespace References