From 282dfc9296f8f90fd5fdd692459a08a2566ad800 Mon Sep 17 00:00:00 2001 From: James Upjohn Date: Fri, 30 Dec 2022 09:34:01 +1300 Subject: [PATCH] fix(filter): check 2 layers of the attribute class' BaseType --- src/Vogen/VoFilter.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Vogen/VoFilter.cs b/src/Vogen/VoFilter.cs index 6f12b65e66..bd7fd2fec7 100644 --- a/src/Vogen/VoFilter.cs +++ b/src/Vogen/VoFilter.cs @@ -22,10 +22,11 @@ public static bool IsTarget(SyntaxNode syntaxNode) => public static IEnumerable TryGetValueObjectAttributes(INamedTypeSymbol voSymbolInformation) { var attrs = voSymbolInformation.GetAttributes(); - + return attrs.Where( - a => a.AttributeClass?.FullName() == "Vogen.ValueObjectAttribute" - || a.AttributeClass?.BaseType?.FullName() == "Vogen.ValueObjectAttribute"); + a => a.AttributeClass?.FullName() == "Vogen.ValueObjectAttribute" + || a.AttributeClass?.BaseType?.FullName() == "Vogen.ValueObjectAttribute" + || a.AttributeClass?.BaseType?.BaseType?.FullName() == "Vogen.ValueObjectAttribute"); } // This is stage 2 in the pipeline - we filter down to just 1 target @@ -34,16 +35,16 @@ public static IEnumerable TryGetValueObjectAttributes(INamedTypeS var voSyntaxInformation = (TypeDeclarationSyntax) context.Node; var semanticModel = context.SemanticModel; - + var voSymbolInformation = (INamedTypeSymbol) semanticModel.GetDeclaredSymbol(context.Node)!; var attributeData = TryGetValueObjectAttributes(voSymbolInformation).ToImmutableArray(); - + if(attributeData.Length > 0) { return new VoTarget( semanticModel, - voSyntaxInformation, + voSyntaxInformation, semanticModel.GetDeclaredSymbol(context.Node)!.ContainingType, voSymbolInformation, attributeData); @@ -71,4 +72,4 @@ public static bool IsTarget(INamedTypeSymbol? voClass) return voAttribute is not null; } -} \ No newline at end of file +}