Push Members Down
This refactoring helps move members and interface implementations from a base type
to one or more derived types.
For example, if you have
MyBaseClass : IMyInterface
and
MyDerivedClass : MyBaseClass
, this refactoring can help you move members of
MyBaseClass
to
MyDerivedClass
or to any of its inheritors.
The refactoring can also move the entire implementation of
IMyInterface
to
MyDerivedClass
or any of its inheritors.
To push members down
-
Select
a type
in one of the following ways:
- In the editor, set the caret at the name of a type.
- Select a type in the Solution Explorer.
- Select a type in the File Structure Window.
- Select a type in the Class View.
- Select a type in the Object Browser.
- Select a type in the type dependency diagram.
-
Do one of the following:
- Press Ctrl+Shift+R and then choose Push Members Down
- Right-click and choose Refactor | Push Members Down on the context menu.
- Choose in the main menu.
- Select one or more destination types from the list of inheritors.
- Select members and/or interfaces that you want to move. You can also click All Public to quickly select all public members and/or Dependent to select members that are referenced by other selected members or implement the selected interfaces.
- For any member, you can select Make abstract (if applicable) to make the member abstract in the current class and create its implementation(s) in the target inheritor class(es).
- To apply the refactoring, click Next.
- If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.
This feature is supported in the following languages/technologies:
C# | VB.NET | C++ | HTML | ASPX | Razor | JavaScript | TypeScript | CSS | XML | XAML | RESX | Build Scripts | Protobuf | 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.