net_automatic_interface icon indicating copy to clipboard operation
net_automatic_interface copied to clipboard

Implement interface inheritance

Open iCodeSometime opened this issue 1 year ago • 2 comments

When two classes inherit from each other, it would be nice if the interfaces did also.

[GenerateAutomaticInterface]
public class Parent : IParent
{
    public void ParentMethod() { }
}
[GenerateAutomaticInterface]
public class Child : Parent, IChild
{
    public void ChildMethod() { }
}

Would generate

public interface IParent
{
    public void ParentMethod();
}
public interface IChild : IParent
{
    public void ChildMethod();
}

iCodeSometime avatar Feb 27 '24 04:02 iCodeSometime

I would be open to a PR but probably will not implement it myself

ChristianSauer avatar Aug 11 '24 08:08 ChristianSauer

I achieve this by chaining my partial interfaces manually. It's minimal effort to achieve what you're looking to do and doesn't introduce a POLA violation.

public partial interface IParent;
public partial interface IChild : IParent;

[GenerateAutomaticInterface]
public class Parent : IParent
{
    public void ParentMethod() { }
}
[GenerateAutomaticInterface]
public class Child : Parent, IChild
{
    public void ChildMethod() { }
}

ChaseFlorell avatar Nov 13 '24 15:11 ChaseFlorell