Using Directives Optimization

To make your code more readable you can exclude unused or redundant Using Directives from your C# and ASP.NET source files. With ReSharper this usually tedious process is reduced to few keystrokes.

To optimize "using" directives:

  1. Press Ctrl + Alt + O or select ReSharper | Code | Optimize Usings in the main menu, in the context menu in the editor, or in Solution Explorer.
    Note   When in Solution Explorer, you can invoke this command on any folder, or on the entire solution. ReSharper will optimize "using" statements throughout the subtree recursively.

    The following dialog appears:

  2. Select the Shorten qualified references checkbox if you want to remove redundant (in the presence of Using directives included) qualifications before the type names.

  3. Click Optimize to remove unused and redundant "using" directives.

Optimize Using Directives process can be also performed as a part of the more advanced Code Reformatting procedure.

The Optimize Usings process will not affect code that is maintained by Windows Form Designer, namely the following regions:

See Also

Advanced Editing Features | Code Reformatting | Code Style Settings | Using Directives Options