All docs
V20.1
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Namespace References Settings

  • 2 minutes to read

You can configure the Sort Namespace References and Optimize Namespace References features for C# and Visual Basic code on the Editor | All Languages | Namespace References options page.

Settings

Refer to the Configuration Options topic for information on how to access this page.

The "Namespace References" page contains the following settings:

Sort Namespace References

This option allows you to specify namespaces sorting order. CodeRush can sort namespaces by length (default mode) or alphabetically.

The following screencast shows the "Sort Namespace References" code formatter that sorts namespace references by length:

Sort

NOTE

CodeRush moves alias to the end of the namespace reference list after sorting is applied.

Place "System" References First

Specifies whether "System" namespace references are always on top after CodeRush applies any sorting. This option is initially disabled.

The screencast below shows how CodeRush places "System" references on the top when the alphabetical sorting is applied for "Sort Namespace References":

System

Group References by First Qualifier

This option allows you to group namespace references by first qualifier (for example, System or DevExpress) when CodeRush sorts namespace references by length. CodeRush also sorts the order of the first qualifiers by length except 'System', if the "Place 'System' references first" option is enabled.

System

Apply Sorting When Optimizing References

This option allows you to disable or enable namespace reference sorting for the "Optimize Namespace References" refactoring.

If "Apply sorting when optimizing references" is disabled, this refactoring only removes unused namespace references.

Never Remove Following References

You can prevent the "Optimize Namespace References" refactoring from removing unused namespace references. For this, add namespace reference(s) to the "Never remove following references" list. This list contains "System" and "System.Linq" namespace references by default.

The following screencast shows the "Optimize Namespace References" refactoring that leaves the unused "System.Drawing" reference in a file:

System