The Convert Interface to Abstract Class refactoring allows you to simplify a local hierarchical dependency among a set of classes and interfaces. This is especially useful when you no longer want a class to implement an interface, thus it makes sense to convert the interface to an abstract class and bring its methods into the new abstract class. The reverse functionality is provided by the Convert Abstract Class to Interface refactoring.
- Place the caret at the name of an interface in the editor, in the File Structure window, in Class View or Object Browser.
Do one of the following:
- On the main menu, choose ReSharper | Refactor | Convert | Interface to Abstract Class
- Choose Refactor | Convert | Interface to Abstract Class on the context menu.
- Press Ctrl+Shift+RCtrl+Shift+R, then click Convert Interface to Abstract Class.
- If no conflicts are found, ReSharper performs the refactoring immediately and the interface is converted into an abstract class with the same name. At the same time, modifiers of methods are changed accordingly. Otherwise, resolve conflicts.
Consider the example below:
After applying the refactoring, the CacheManager interface is converted into an appropriate abstract class: