daver32 / InterfaceGenerator

A simple source generator that creates interfaces by implementations.
MIT License
36 stars 13 forks source link

Nullable Annotations should be taken over to the interface. #19

Open mtren opened 1 year ago

mtren commented 1 year ago

Curent Behaviour: For the class

[InterfaceGenerator.GenerateAutoInterface(VisibilityModifier = "public")] public class AClass : IAClass {

    [return: NotNullIfNotNull(nameof(content))]
    public byte[]? TheMethod(byte[]? content)
    {
        if (content == null) return content;
        return content;
    }
}

this interface is generated: public partial interface IAClass { byte[]? TheMethod(byte[]? content); }

Excpected Interface:

public partial interface IAClass
{
    [return: NotNullIfNotNull(nameof(content))]
    byte[]? TheMethod(byte[]? content);
}

Also other paremeter Attributes should be considered. Eg. MaybeNullWhen() or EnumeratorCancellation.