The Pull Members Up refactoring helps pull type members from an inheritor up the inheritance hierarchy to a base type. This operation is useful when you want to generalize the behavior of the superclass.
ReSharper analyzes all members in the current class and makes the list of members that you can move to a superclass or interface. Before completing the refactoring, ReSharper also checks for possible conflicts, for example, whether the members you are trying to move to the base class will be accessible in the destination type.
Reverse functionality is available with the Push Members Down refactoring.
- Place the caret at a class that you want to pull members up from or at a particular member in the editor. In the latter case the member will be initially selected in the Pull Members Up dialog box.
Do one of the following:
- On the main menu, choose ReSharper| Refactor | Pull Members Up.
- Choose Refactor | Pull Members Up on the context menu.
- Press Ctrl+Shift+R, then click Pull Members Up.
The Pull Members Up dialog box opens.
Select a destination base type from the list of available
types at the top of the dialog box.
Select members list, select members of the current type that you want to pull up. Optionally, click one of the following buttons:
- All Public to select all public members of the current type.
- Dependent to select members that are referenced by any other previously selected members.
- For any member, select Make abstract (if applicable) to create an abstract member in the selected base type and leave its implementation in the current type.
- Click Next. If no conflicts are found, the refactoring is performed immediately. Otherwise, resolve conflicts.