C#

C#

Made by DeepSource

abstract classes with only abstract methods should be declared as interfaces CS-R1078

Anti-pattern
Major

The abstract keyword in C# indicates that an entity is missing its full implementation and that is responsbility of the inheritor to complete or fulfil it. The said keyword applies to both classes and methods. If a class is declared as an abstract class and only has abstract methods, it is more suitable to convert it to an interface as interfaces are designed for the exact same purpose. Meaning, an abstract class should have at least some minimal implementation. If a class was declared abstract to prevent users from instantiating it, consider changing the constructor's visibility.

Bad Practice

abstract class Foo
{
    public abstract void Bar();
    public abstract void Baz();
}

Recommended

interface IFoo
{
    public abstract void Bar();
    public abstract void Baz();
}

Reference