我打算将新的Roslyn Code Analysis API与MVC 6项目一起使用。
但是,当我运行此代码时:
string pathToSolution = @"..\..\..\WebApplicationComplex.sln";
const string projectName = "RoslynWebAPIProject";
MSBuildWorkspace workspace = MSBuildWorkspace.Create();
Solution solutionToAnalyze = workspace.OpenSolutionAsync(pathToSolution).Result;
Project sampleProjectToAnalyze = solutionToAnalyze.Projects.Where((proj) => proj.Name == projectName).FirstOrDefault();
Compilation sampleToAnalyzeCompilation = sampleProjectToAnalyze.GetCompilationAsync().Result;
我只获得了分析器项目而没有获得MVC 6项目,因此sampleProjectToAnalyze
仍然为空。
我该如何分析这类项目?