JetBrains Rider 2017.2 Help

Convert Interface to Abstract Class refactoring

This refactoring converts interfaces into abstract classes thus helping you quickly change hierarchical dependency among a set of classes and interfaces.

Consider the following example:

Before refactoringAfter refactoring
interface Shape { double Area { get; } void Draw(); } class Circle : Shape { private readonly int radius; public double Area { get { return Math.PI*Math.Pow(radius, 2); } } public void Draw() { //do something } }
abstract class Shape { public abstract double Area { get; } public abstract void Draw(); } class Circle : Shape { private readonly int radius; public override double Area { get { return Math.PI*Math.Pow(radius, 2); } } public override void Draw() { //do something } }

To turn a suitable interface into an abstract class

  1. Select an interface in one of the following ways:
    • In the editor, set the caret at the name of an interface.
    • Select an interface in the Structure window.
  2. Do one of the following:
    • Press Ctrl+Shift+R and then choose Convert Interface to Abstract Class
    • Choose Refactor | Convert Interface to Abstract Class in the main menu.
  3. If no conflicts are found, JetBrains Rider performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.
Last modified: 17 November 2017

See Also