This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TargetTypeTracker : ISyntaxContextReceiver | |
{ | |
public IImmutableList<TypeDeclarationSyntax> TypesNeedingDtoGening = | |
ImmutableList.Create<TypeDeclarationSyntax>(); | |
public void OnVisitSyntaxNode(GeneratorSyntaxContext context) | |
{ | |
if (context.Node is TypeDeclarationSyntax cdecl) | |
if (cdecl.IsDecoratedWithAttribute("generatemappeddto")) | |
TypesNeedingDtoGening = TypesNeedingDtoGening.Add( | |
context.Node as TypeDeclarationSyntax); | |
} | |
} | |
internal static class SourceGenExtns | |
{ | |
internal static bool IsDecoratedWithAttribute( | |
this TypeDeclarationSyntax cdecl, string attributeName) => | |
cdecl.AttributeLists | |
.SelectMany(x => x.Attributes) | |
.Any(x => x.Name.ToString().ToLower() == attributeName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment