This project is read-only.

Am I able to refresh diagnostics on settings change in Roslyn

Topics: APIs, General
Nov 13, 2014 at 4:53 PM
Let's say that I've created a diagnostic analyzer that shows warning if an IfStatementSyntax does not have opening and closing braces. Also, my Visual Studio extension has setting allowing to the user to disable such kind of diagnostics. What I am trying to achieve is to invalidate the current diagnostics when this setting has been change because they might be inadequate. Am I able to do this somehow?
Nov 13, 2014 at 7:14 PM
Unfortunately, there's no mechanism for this today. Triggering analysis and\or managing incrementality is done by the analysis driver and not by the diagnostic authors. If any of the options that were passed to the language service change, then we trigger reanalysis. But if this is an option that VS doesn't know about then we wouldn't know to trigger reanalysis.

This also points to another gap that today, we don't have a good story for analyzers getting options passed to them. We have some thoughts on how to implement such a feature but we haven't gotten around to doing it yet.
Dec 20, 2014 at 8:13 PM

When you say you retriger the analysis. Does that mean the initialize methods in each diagnostics get called again. If so any pointers on how to change the options new options that were passed to the analyis service
Jan 2, 2015 at 9:24 PM
Not the Initialize method but the actions that you register (for eg with RegisterSymbolAction) will get called again (if the analyzer engine deems it necessary based on the nature of the change).

If you're asking how to get at the options passed to the service there's no way currently. Giving diagnostic authors the ability to get at ambient options is a features that's not been added yet.