Skip to main content
A newer version of this page is available. .

Rename Namespace to Match Folder Structure

  • 2 minutes to read

Purpose

Renames a namespace name according to the project default namespace and the path to the source code file in which the namespace is declared.

Rename Namespace to Match Folder Structure is a cascading refactoring. It affects all method calls and method declarations in interfaces, base and descendant classes.

Availability

Available when the cursor is in a namespace name definition. The namespace name should be different than the path to the source code file which contains the namespace definition.

How to Use

  1. Place the caret in a namespace name declaration.

    Note

    The blinking cursor shows the caret’s position at which the Refactoring is available.

    //File path: DevExpress.CodeRush.TestRunner\Options\TestRunnerOptionsPage.xaml.cs
    
    namespace TestRunnerOptions {
        // ...
    }
    
  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
  3. Select Rename Namespace to Match Folder Structure from the menu.

After execution, the Refactoring changes the name of the namespace to match the location of the file which contains the namespace definition.

//File path: DevExpress.CodeRush.TestRunner\Options\TestRunnerOptionsPage.xaml.cs

namespace DevExpress.CodeRush.TestRunner.Options {
    // ...
}

XAML Support

You can run Rename Namespace to Match Folder Structure in:

  • XAML file

    RemoveQualifier

  • XAML code behind file

    RemoveQualifier

Sync Namespace with Folder Structure

You can use the Sync Namespace with Folder Structure item in the Solution Explorer’s context menu. This item is available for folders and projects which contain files with namespaces.

RemoveQualifier

Note

To improve performance on large projects, the Sync Namespace with Folder Structure menu item is always available even if all namespaces are already synced up to the folder structure.