Skip to content

Enum to disable member creation for inherited classes or interfaces #91

@ChaseFlorell

Description

@ChaseFlorell

Proposal: add a new inheritanceGeneration parameter to the GenerateAutomaticInterfaceAttribute so that we can turn off the unnecessary inheritance.

The rationale comes from all of my classes that implement IDisposable, and that I really don't need the Dispose() method defined in my custom interface.. and if I do, I'll do it myself public partial interface IMyClass : IDisposable;

[Flags]
public enum InheritanceGeneration
{
    AllowAll = 0, // default - prevents breaking changes
    DisableInterfaces = 1 << 0,
    DisableConcretions = 1 << 1,
    DisableAll = DisableInterfaces | DisableConcretions
}

Given a setup as follows

public class SomeBase
{
    public void SomeMethod(){}
}

[GenerateAutomaticInterface(allowInheritanceGeneration = InheritanceGeneration.DisableAll)]
public sealed class MyClass : SomeBase, IDisposable
{
    public void MySpecialMethod(){}
}

the automatic interface would be akin to

public interface IMyClass
{
    void MySpecialMethod();
}

note: naming is up for debate, its the concept that I'm advocating for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions