You can easily navigate the a Syntax Tree using LINQ. For example it is easy to get all the ClassDeclarationSyntax
nodes (declared classes), that have a name starting with the letter A
:
var allClassesWithNameStartingWithA = syntaxRoot.DescendantNodes()
.OfType<ClassDeclarationSyntax>()
.Where(x => x.Identifier.ToString().StartsWith("A"));
Or getting all the classes that have attributes:
var allClassesWithAttriutes = syntaxRoot.DescendantNodes()
.OfType<ClassDeclarationSyntax>()
.Where(x => x.AttributeLists.Any(y => y.Attributes.Any()));