Back to Devexpress

Sort Namespace References

coderushforroslyn-115577-code-style-assistance-code-formatters-sort-namespace-references.md

latest1.7 KB
Original Source

Sort Namespace References

  • Aug 03, 2020
  • 2 minutes to read

Purpose

Sorts namespace references in the “using” (C#) or “Imports” (Visual Basic) section alphabetically or by length.

Availability

Available when the cursor is in a using ( Imports ) statement if the namespace references are not sorted.

Usage

  1. Open the Editor | All Languages | Namespace References options page to configure this code formatter. 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 Sort Namespace References from the menu.

After execution, the Code Formatter sorts the namespace references alphabetically.

csharp
using Mono.Cecil.Cil;
using Mono.Cecil.Metadata;
using Mono.Cecil.PE;
using Mono.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.UInt32;
vb
Imports Mono.Cecil.Cil
Imports Mono.Cecil.Metadata
Imports Mono.Cecil.PE
Imports Mono.Collections.Generic
Imports System
Imports System.Collections.Generic
Imports System.IO
Imports System.IO.Compression
Imports System.Text
Imports System.UInt32

Note

This feature is available as a part of Code Cleanup.

See Also

Optimize Namespace References