Otaman / Copycat

Source generators for creating decorators by templates
MIT License
1 stars 1 forks source link

Does not work for properties in the interface #2

Closed ignatandrei closed 10 months ago

ignatandrei commented 10 months ago

Let's say that we have this interface:

internal interface ICoffee
{
    //string? Name { get; set; }
    Task<bool> Prepare();

    string[] GetIngredients();
}

If we uncomment the Name property, the error in build is

1>CSC : warning CS8785: Generator 'DecoratorGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax'.'.

I can provide a project , if needed

Otaman commented 10 months ago

Issue is clear, thanks. It's time for me to provide at least pass through implementation for properties, events, indexers. And finally to dig into C# 11 static abstract feature for interface's members... :)

ignatandrei commented 10 months ago

However, I was impressed by the easy of use. https://ignatandrei.github.io/RSCG_Examples/v2/docs/CopyCat , if you want to see the result

Otaman commented 9 months ago

@ignatandrei Thank you for your effort and feedback. I'm glad to tell I've added pass through implementation for properties, events, indexers in the recent build 0.4.0-beta.1 Your code should work well now.