codecentric / net_automatic_interface

.Net Source Generator for Automatic Interfaces
MIT License
62 stars 14 forks source link

Implement interface inheritance #35

Open iCodeSometime opened 9 months ago

iCodeSometime commented 9 months ago

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();
}
ChristianSauer commented 3 months ago

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

ChaseFlorell commented 1 week ago

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() { }
}