codecentric / net_automatic_interface

.Net Source Generator for Automatic Interfaces
MIT License
60 stars 13 forks source link

out keyword in method parameter is missing in interface #38

Closed konrad-gora closed 6 months ago

konrad-gora commented 7 months ago

This is my class:

[GenerateAutomaticInterface]
public class SomeClass : ISomeClass
{
    public void SomeMethod(out int someOutParameter)
    {
        someOutParameter = 1;
    }
}

This is the generated interface:

[GeneratedCode("AutomaticInterface", "")]
public partial interface ISomeClass
{
    /// <inheritdoc />
    void SomeMethod(int someOutParameter);

}

The out keyword is missing in the interface. Because of that, I'm getting a compilation error: CS0535 'SomeClass' does not implement interface member 'ISomeClass.SomeMethod(int)'

mohummedibrahim commented 7 months ago

@konrad-gora Yes, I'm also having the same issue with ref and in too. Looks like the out, ref, and in are not implemented yet in the source generator.

@ChristianSauer A quick fix/implementation could be perhaps checking RefKind on IParameterSymbol in Builder class. i.e. I gave it a try here and it worked. https://github.com/mohummedibrahim/net_automatic_interface/commit/1613ad1b371d0dd727ce09eaf32d8866f56e0054

ChristianSauer commented 6 months ago

Should be in 2.3.0

konrad-gora commented 6 months ago

I can just confirm that it is working now :)