Move Type

The Move Type refactoring allows users to move a given class, struct, delegate, or enum to another namespace or to isolate it in a separate file. All references to the type in code are corrected automatically.

Note   To move an inner type, see description of the Move Type to Outer Scope and Move Static Member refactorings.

 

To move a type

  1. Select the class, interface, struct, or enum 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 | Move.
    • Right-click the type, and on the shortcut menu click Refactor | Move.
    • Press F6.
    • Press Ctrl + Shift + R, and then select Move.

    The Move Type dialog opens.

  3. If you want to move the type to another namespace, select the Another namespace option. In this case, using directives and qualified names of the type will be updated.
    1. In the Namespace text box, type or browse for the destination namespace. In the latter case, you can select the target namespace in the devoted dialog box that displays the namespace hierarchy in the project or solution.

    2. If you want the find and change the full qualified type name in comments and strings, select the Search in comments and string literals check box.
    3. Click Continue.
    4. If you selected the Search in comments and string literals check box, ReSharper displays found usages (if any) in the following dialog box.

    5. 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.
  4. If you want to extract the type to another file, select the Another file option.
    1. In the File text box, type the file name. You can specify an existing file as well as type a name for a new file. In the latter case, the new file will be created in the current folder.
    2. Click Continue.

The names and references are updated immediately.

See Also

Refactoring Code