ReSharper Web Help

The Extract Interface refactoring helps create a new interface based on a selected interface or class.

ReSharper analyses the selected interface or class to detect members that can be transferred to the new interface. After extraction, the original interface or class is updated to implement the new interface.

To extract an interface
  1. Place the caret at the declaration of an interface or class in the editor, in the File Structure window, in Object Browser or in Class View.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Refactor | Extract Interface.
    • Right-click, then click Refactor | Extract Interface on the context menu.
    • Press Ctrl+Shift+R, then click Extract Interface.
  3. The Extract Interface dialog box opens:

  4. In the Name of new interface text box, type the name of a new interface or leave the default one.
  5. Click Place beside or Place in another file to define the physical location of the interface.
  6. The list of members contains:
    • Members of the current class.
    • Members of any base classes or interfaces that the selected class currently inherits/implements.
    • Names of interfaces that the selected class currently implements.
    Select members that you want to transfer to the new interface.

     Note

    If you select the name of an interface that the refactored interface or class implements, it will be implemented in the extracted interface instead of the current class/interface. For example, if you refactor interface ICurrent that implements interface IImplemented, and you select the name of IImplemented in the list of members, then after the refactoring is completed, ICurrent will implement the newly created interface INew, which will in turn implement IImplemented.
  7. To extract all listed public members, click All Public.
  8. If you have selected members that reference other members, the latter are highlighted with red. Click Dependent to resolve the conflict, i.e. to select any members that depend on the currently selected members.
  9. Click Next. If no conflicts are found, the refactoring will be applied immediately, otherwise, resolve conflicts.

See Also

Procedures

External Links