/// <summary> /// Finds all P# machines in the project. /// </summary> private static void FindAllMachines() { // Iterate the syntax trees for each project file. foreach (var tree in AnalysisContext.Compilation.SyntaxTrees) { if (!AnalysisContext.IsProgramSyntaxTree(tree)) { continue; } // Get the tree's semantic model. var model = AnalysisContext.Compilation.GetSemanticModel(tree); // Get the tree's root node compilation unit. var root = (CompilationUnitSyntax)tree.GetRoot(); // Iterate the class declerations only if they are machines. foreach (var classDecl in root.DescendantNodes().OfType <ClassDeclarationSyntax>()) { if (Querying.IsMachine(AnalysisContext.Compilation, classDecl)) { AnalysisContext.Machines.Add(classDecl); } } } }