public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
 {
     if (syntaxNode is ClassDeclarationSyntax classDeclarationSyntax &&
         classDeclarationSyntax.AttributeLists.Count > 0)
     {
         CandidateClasses.Add(classDeclarationSyntax);
     }
 }
示例#2
0
 public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
 {
     if (syntaxNode is ClassDeclarationSyntax {
         AttributeLists : { Count : > 0 }
     } classDeclarationSyntax &&
         classDeclarationSyntax.Modifiers.Any(SyntaxKind.PartialKeyword))
     {
         CandidateClasses.Add(classDeclarationSyntax);
     }
 }
示例#3
0
        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);
            }
        }
示例#4
0
        /// <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);
            }
        }