ReSharper 2016.3 Help

Move Types into Matching Files

ReSharper | Refactor | Move Types Into Matching Files…

This command is a bulk fix that helps you organize types and/pr delegates so that each type/delegate definition is located in a single file with the matching name. I.e. if there are several types/delegates declared in a single files, new files are created for each declaration; if a file name does not match the single type/delegate declaration it contains, then the file is renamed.

All required imports are added in new files; all imports that are no longer necessary are removed from the original files.

To move types into matching files

  1. In the Solution Explorer, select a node where you want to organize types into matching files.
  2. Do one of the following:
    • Press Ctrl+Shift+R and then choose Move Types into Matching Files
    • Right-click and choose Refactor | Move Types into Matching Files in the context menu.
    • Choose ReSharper | Refactor | Move Types Into Matching Files… in the main menu.
    The Move Types into Matching Files dialog will open.
  3. Select the kinds of declarations that should be moved into matching files.
    Moving types to matching files
  4. To apply the refactoring, click Next.
  5. If there are no conflicts, the refactoring is performed immediately. If there are existing files that conflict with newly created or renamed files, the wizard displays a page with conflicts. You can double-click conflicts to navigate to the corresponding declarations and fix them.

You can also move a single type into the matching file right from the editor using a context action or apply this action in a larger scope (which will give you the same result as performing the refactoring):

Moving type to matching file

Mismatching type and file names can be also fixed from the editor with a context action:

Renaming file to match type name

You can also move any type to a new or existing file using the Move Type to Another File refactoring.

See Also


Last modified: 20 January 2017