Rename Refactorings

The Rename refactorings allows users to change names of namespaces, classes, structs, methods, and fields. All corresponding references in the code are updated automaticaly.

The following rename refactorings are available:

Whenever you rename a class, a method, or some other symbol, the basic steps of the Rename refactoring are practically the same.

To rename a symbol

  1. Select the symbol (namespace, class, struct, method, or field) either in Class View or Object Browser, or position the caret at its name in the editor.
  2. Do one of the following:
    • On the main menu, click ReSharper | Refactor | Rename.
    • Right-click the symbol, and on the shortcut menu click Refactor | Rename.
    • Press F2.
    • Press Ctrl + Shift + R, and then select Rename.

    The following dialog box opens.

  3. If you want the changes to be applied to comments and strings, select the Search in comments and string literals check box.
  4. In the text field, specify a new name and click Continue.
  5. If there are related symbols whose names contain the changed string (for example, read and write properties of a field or variables of a class whose names are based on a class name), the following dialog appears.

  6. Select the check boxes next to the symbols you want to rename, and click Continue.
    Note   You can navigate to the locations of related symbols and correct the code manually. The list of the related symbols will be updated according to your changes.
  7. If on the first step you selected the Search in comments and string literals check box, ReSharper displays found usages (if any) in the following dialog box.

  8. Select the check boxes next to the items you want to rename, and click Continue.
    Note   You can navigate to the locations of the usages and correct them manually. The list of the usages will be updated according to your changes.

If no conflicts are found, the names and references are updated immediately.

Rename Namespace

The Rename Namespace refactoring allows users to rename a specific namespace and automatically correct all references to the namespace in the code.

The following usages are renamed:

Note   When you rename a namespace, you can also change its nesting level. For example, you can rename some A.B.C namespace to A.D.

Rename Type

The Rename Type refactoring allows users to rename a specific interface, class, struct, or enum and automatically correct all references to the type in the code.

The following usages are renamed:

If the renamed type is located in the file with the same name, ReSharper suggests to rename the file too.

Rename Method

The Rename Method refactoring allows users to rename a specific method and automatically correct all references to the method in the code.

The following usages are renamed: