public void OnVisitSyntaxNode(SyntaxNode syntaxNode) { if (syntaxNode is ClassDeclarationSyntax classDeclarationSyntax && classDeclarationSyntax.AttributeLists.Count > 0) { CandidateClasses.Add(classDeclarationSyntax); } }
public void OnVisitSyntaxNode(SyntaxNode syntaxNode) { if (syntaxNode is ClassDeclarationSyntax { AttributeLists : { Count : > 0 } } classDeclarationSyntax && classDeclarationSyntax.Modifiers.Any(SyntaxKind.PartialKeyword)) { CandidateClasses.Add(classDeclarationSyntax); } }
public void OnVisitSyntaxNode(SyntaxNode syntaxNode) { if (syntaxNode is ClassDeclarationSyntax cds && cds.AttributeLists.Count > 0) { CandidateClasses.Add(cds); return; } if (syntaxNode is EnumDeclarationSyntax eds && eds.AttributeLists.Count > 0) { CandidateEnums.Add(eds); } }
/// <summary> /// Called for every syntax node in the compilation, we can inspect the nodes and save any information useful for generation /// </summary> public void OnVisitSyntaxNode(SyntaxNode syntaxNode) { var classes = new List <JsonClass>(); // any method with at least one attribute is a candidate for property generation if (syntaxNode is ClassDeclarationSyntax classDeclarationSyntax && classDeclarationSyntax.AttributeLists.Count > 0) { CandidateClasses.Add(classDeclarationSyntax); } if (syntaxNode is AttributeSyntax attributeSyntax) { CandidateAttributes.Add(attributeSyntax); } }