ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Extract Interface refactoring

Last modified: 21 July 2022

ReSharper | Refactor | Extract | Extract Interface…

To assign a shortcut, go to Tools | Options | Environment | Keyboard and find the ReSharper_ExtractInterface command.

This refactoring helps create a new interface based on a selected type. ReSharper suggests choosing members to be transferred to the new interface. After extraction, the original type is updated to implement the new interface.

If the current type already implements any interfaces, those interfaces can also be extracted into the new interface.

In the example below, the Color property and the Draw method of the Circle class are extracted to create a new interface:

ReSharper. Extracting interface from a class

This feature is supported in the following languages and technologies:

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.