Rename Namespace To Match Folder Structure
- 2 minutes to read
Purpose
Used to bring the name of the namespace in line with the location of the source code file containing the namespace definition. The best coding practices require each namespace name to correspond the physical location of the file containing its definition.
NOTE
- Rename Namespace To Match Folder Structure is a cascading Refactoring. That means that the Refactoring affects all method calls and method declarations in interfaces, base and descendant classes.
- Rename Namespace To Match Folder Structure is a cross-language Refactoring. This means that this Refactoring can make required changes in projects in any supported language (see the code snippet below).
Availability
Available when the cursor is on a namespace name in its definition, assuming that this name differs from the path to the source code file containing the namespace definition.
Usage
Place the caret on a namespace name in its declaration.
NOTE
The blinking cursor shows the caret's position at which the Refactoring is available.
- Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
- Select Rename Namespace To Match Folder Structure from the menu.
After execution, the Refactoring changes the name of the namespace to match the physical location of the file containing the namespace definition.