-
I'm trying to read Diagnostics message in experimental visual studio instance while creating/testing new analyzer. However I'm not getting the diagnostics messages which are published by analyzer created by me. I can see those messages in visual studio's error list, error symbol is getting highlighted but I want to read those message which are posted in error list. I tried following method for reading, SemanticModel semanticModel = vsWorkspace.CurrentSolution.GetDocument(location.SourceTree).GetSemanticModelAsync().Result; It list some messages which are hidden but not returning messages which are seen in error list and posted during analysis. How can I read those diagnostics messages? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Today if you do ImmutableArray<DiagnosticAnalyzer> analyzers = ... // set of analyzers you want to run
Compilation compilation = await vsWorkspace.CurrentSolution.GetDocument(location.SourceTree).Project.GetCompilationAsync();
CompilationWithAnalyzers compilationWithAnalyzers = compilation.WithAnalyzers(analyzers);
AnalysisResult analysisResult = await compilationWithAnalyzers.GetAnalysisResultAsync() analysisResult will contain all the analyzer diagnostics from runnint the analyzers over the project. @kulamit which version of VS are you using? we plan to change where analyzers run in the near future. |
Beta Was this translation helpful? Give feedback.
semanticModel.GetDiagnostics()
does not cause analyzers to run, it only asks the compiler to compute diagnostics.Today if you do
analysisResult will contain all the analyzer diagnostics from runnint the analyzers over the project.
@kulamit which version of VS are you using? we plan to change where analyzer…