Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: source generated partials when using attributes derived from ValueObjectAttribute<T> #321

Merged
merged 3 commits into from
Jan 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(filter): check 2 layers of the attribute class' BaseType
  • Loading branch information
jupjohn committed Jan 6, 2023
commit 282dfc9296f8f90fd5fdd692459a08a2566ad800
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;
}
}
}