The Extract Superclass refactoring allows to extract certain members from a selected class to a new superclass.
ReSharper analyses the selected class and detects the superclasses and interfaces it inherits from, as well as its members that can be transferred to a new superclass. The original class will inherit from the superclass.
- Place the caret at the declaration of a class in the editor.
Do one of the following:
- On the main menu, choose ReSharper | Refactor | Extract Superclass.
- Right-click, then click Refactor | Extract Superclass on the context menu.
- Press Ctrl+Shift+RCtrl+Shift+R, then click Extract Superclass.
The Extract Superclass dialog box opens.
In the Name of new class text box,
type a name for a new superclass or leave the default one.
- Click Place beside or Place in another file to define the physical location of the new superclass.
- In the list of members, select members that you want to transfer to the new superclass.
- To make/keep individual members abstract, select corresponding Make Abstract check boxes where available.
- To extract all public members of the current class, click All Public.
- If you select members that reference other members, the latter are highlighted with red, as shown in figure above. Click Dependent to resolve the conflict, i.e. to select any members that depend on the currently selected members.
- Click Next. If no conflicts are found, the refactoring will be applied immediately, otherwise, resolve conflicts.