Home > Refactorings > Refactorings – Move Type to File

Refactorings – Move Type to File

January 19th, 2011

The Move Type To File refactoring allows users to move a given class, structure, interface, enumeration or delegate to a separate file. It is available when there are two or more types in the current source file.

Refactoring moves a type with a name that differs from the file name to a new source file. All comments, attributes, and XML doc comments relating to the type are moved with the type. The file will be located in the same folder as the current file and automatically added to the project. The name of the new file is based on the type’s name on which refactoring is applied.

To perform the Move Type to File refactoring, place the editor caret at the type name, or a visibility keyword if specified. If visibility keyword is not specified than the first keyword range is used instead (e.g. ‘class’ (CSharp) or ‘Class’ (Visual Basic)).

After refactoring is executed, all namespace references in the new source file are automatically optimized, i.e. all unused namespace references are removed using the existing Optimize Namspace References refactoring.

—–
Products: Refactor! Pro, CodeRush Xpress
Versions: 10.2 and up
VS IDEs: any
Updated: Apr/18/2011
ID: R019

Similar Posts: