How AnalyzerManager and ProjectAnalyzer work together
mainBuildalyzer uses two primary classes to coordinate project analysis:
AnalyzerManager: The entry point. It coordinates loading individual projects and can consolidate information from a solution file if a solution path is provided to its constructor. It maintains a collection of loaded projects in itsProjectsproperty (IReadOnlyDictionary<string, ProjectAnalyzer>).ProjectAnalyzer: Represents a specific project. It handles the MSBuild configuration and executes a design-time build. A design-time build evaluates MSBuild tasks and targets to resolve references and source files without actually invoking the compiler, making it high-performance.
To use them, create an AnalyzerManager, use GetProject(path) to obtain an IProjectAnalyzer, and then call Build() to perform the analysis.
AnalyzerManager manager = new AnalyzerManager();
IProjectAnalyzer analyzer = manager.GetProject(@"C:\MyCode\MyProject.csproj");
IAnalyzerResults results = analyzer.Build();
string[] sourceFiles = results.First().SourceFiles;