SteveDunn / Vogen

A semi-opinionated library which is a source generator and a code analyser. It Source generates Value Objects
Apache License 2.0
887 stars 46 forks source link

Generator breaks if _any_ Generic attributes use an array type #575

Closed Blackclaws closed 6 months ago

Blackclaws commented 7 months ago

Describe the bug

Use this code with Vogen installed:

public class Test<T> : Attribute
{

}

[Test<byte[]>]
public class Test
{

}

[ValueObject<string>]
public partial class Value;

Vogen will fail to produce source with the error: 0>CSC: Warning CS8785 : Generator 'ValueObjectGenerator' 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.Symbols.PublicModel.ArrayTypeSymbol' to type 'Microsoft.CodeAnalysis.INamedTypeSymbol'.'.

Steps to reproduce

  1. Take source above and run
  2. See error

Expected behaviour

Vogen generates source