ReSharper 2021.1 Help

Move to Another Type refactoring

ReSharper | Refactor | Move…
F6
ReSharper_Move

This refactoring helps you move nested types and static members to another type (an existing one or a new one). All references and usages are automatically updated, including scenarios where a member uses other members of its original type.

Invoke the refactoring with a command

  1. Select a nested type or a static member in one of the following ways:

    • In the editor, set the caret at the name of a nested type.

    • Select a nested type in the Solution Explorer.

    • Select a nested type in the File Structure window.

    • Select a nested type in the Class View.

    • Select a nested type in the Object Browser.

    • Select a nested type in the type dependency diagram.

  2. Do one of the following:

    • Press F6 and then choose Move To Another Type

    • Press Control+Shift+R and then choose Move To Another Type

    • Right-click and choose Refactor | Move To Another Type in the context menu.

    • Choose ReSharper | Refactor | Move… in the main menu.

    The Move To Another Type dialog will open.

  3. Start typing the name of the target type. If you are moving the item to an existing type, pick it from the drop down list that displays all types in the solution matching your input.

  4. If necessary, you can move other nested types and static members of the containing type to another type. To do so, select the desired items in the Static Members to Move area.

  5. Optionally, specify access modifiers for the mvoed symbols in the new type.

  6. To apply the refactoring, click Next.

  7. If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.

ReSharper.'Move to Another Type' refactoring

Perform the refactoring in-place

You can apply the refactoring by cutting a nested type or a static member and pasting it into another type. As soon as you paste the item, a grey border appears around it and a popup is shown, notifying you that the refactoring is available. You can click the suggestion or press Alt+Enter to invoke the solution-wide refactoring:

ReSharper refactorings: Inplace refactorings, move static members

Applicability in different languages

This feature is supported in the following languages and technologies:

Language: C#Language: VB.NETLanguage: C++Language: HTMLLanguage: ASP.NETLanguage: RazorLanguage: JavaScriptLanguage: TypeScriptLanguage: CSSLanguage: XMLLanguage: XAMLLanguage: ResxLanguage: Build ScriptsLanguage: ProtobufLanguage: JSON
Feature is available in C#Feature is available in Visual Basic .NET Feature is not available in C++ Feature is not available in HTML Feature is not available in ASP.NET Feature is not available in Razor Feature is not available in JavaScript Feature is not available in TypeScript Feature is not available in CSS Feature is not available in XML Feature is not available in XAML Feature is not available in Resource files Feature is not available in build script files Feature is not available in Protobuf Feature is not available in JSON

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by Language section.

Last modified: 08 March 2021