Skip to content

Commit

Permalink
fix(filter): check 2 layers of the attribute class' BaseType
Browse files Browse the repository at this point in the history
  • Loading branch information
jupjohn committed Dec 29, 2022
1 parent 7c75050 commit b11b363
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Vogen/VoFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ internal static class VoFilter
public static IEnumerable<AttributeData> 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
Expand All @@ -34,16 +35,16 @@ public static IEnumerable<AttributeData> 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);
Expand Down Expand Up @@ -71,4 +72,4 @@ public static bool IsTarget(INamedTypeSymbol? voClass)

return voAttribute is not null;
}
}
}

0 comments on commit b11b363

Please sign in to comment.