Convert Abstract Class to Interface refactoring
This refactoring allows you to convert an abstract class to an interface. This can be useful when you want a class to inherit from more than one abstract classes — then you can easily convert one of them to an interface.
Consider the example below. After applying the refactoring, a class is converted into an interface:
Convert an abstract class into an interface
Select an abstract class in one of the following ways:
In the editor, place the caret at the name of an abstract class.
Select an abstract class in the Solution Explorer.
Select an abstract class in the Structure window.
Do one of the following:
Press Control+Alt+Shift+T and then choose Convert Abstract Class to Interface.
Choose
from the main menu.
If the abstract class contains non-abstract members, JetBrains Rider shows you a dialog notifying that the bodies and/or accessors of such members will be removed. To avoid this, you need to move the logic of non-abstract members to child classes or elsewhere manually, and then invoke the refactoring again.
If no conflicts are identified, the abstract class is converted into an interface with the same name, and modifiers of abstract members are changed accordingly. Otherwise, resolve conflicts.
By default, the naming style for interfaces requires interface names to start with I
. Therefore, if you did not change the settings, the interface name will be highlighted as inconsistently named. Just press Alt+Enter and use the corresponding quick-fix to rename the interface.