Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering is broken for analyzers reporting diagnostics with ID not beloging to any descriptor returned by SupportedDiagnostics #252

Closed
srivatsn opened this issue Feb 5, 2015 · 0 comments · Fixed by #1286

Comments

@srivatsn
Copy link
Contributor

srivatsn commented Feb 5, 2015

Ported from TFS WorkItem: 1100829


Repro Steps:


1. Write a diagnostic analyzer with single descriptor with ID say "Rule1" returned in DiagnosticAnalyzer.SupportedDiagnostics

2. Report a diagnostic with a different ID, say "Rule2", in the analyzer

3. Start VS experimental instance with the analyzer and create a test that fires "Rule2".

 

Expected: "Rule2" diagnostic is filtered out as the SupportedDiagnostics didn't return a descriptor with Rule2

Actual: "Rule2" is reported. Additionally, you cannot configure "Rule2" in ruleset editor as it is not part of SupportedDiagnostics.

 

We should probably also write a Roslyn meta-analyzer to detect this scenario and flag the incorrect ReportDiagnostic invocation.


Revisions:

  1. Created By Manish Vasani (12/29/2014 11:09:34 AM)

  1. Edited By Srivatsn Narayanan (1/9/2015 9:56:28 AM)

You've already written the roslyn analyzer for this now right?


  1. Edited By Manish Vasani (1/9/2015 10:05:01 AM)

Yes, the analyzer is written, but we need to still implement the logic in the drivers to filter reported diagnostics with unsupported ID.

Without this change, the analyzer's claim that unsupported diagnostics will not be reported is invalid as we will report even unsupported diagnostic reported by analyzer.


  1. Edited By Srivatsn Narayanan (1/9/2015 1:01:10 PM)

Ah i misunderstood. Yes we should do that. The things stopping us from doing it before was the the compiler and the EnC analyzer were both producing diagnostics that werent reported through SupportedDiagnostics. I think we are fine on both counts now. Let's make this change.


@srivatsn srivatsn added this to the 1.0-rc2 milestone Feb 5, 2015
@srivatsn srivatsn modified the milestones: 1.0 (stable), 1.0-rc2 Feb 10, 2015
mavasani added a commit to mavasani/roslyn that referenced this issue Mar 17, 2015
…orted diagnostic ID, i.e. no descriptor returned by SupportedDiagnostics has that ID, then throw an ArgumentException in ReportDiagnostic method. This exception would be turned into an analyzer diagnostic by the driver and reported back to the analyzer host.

Also fix a few tests that were reporting diagnostics with unsupported ID!
mavasani added a commit that referenced this issue Mar 17, 2015
Handle unsupported diagnostics reported by analyzers.

Fixes #252 : If an analyzer reports a diagnostic with an unsupported diagnostic ID, i.e. no descriptor returned by SupportedDiagnostics has that ID, then throw an ArgumentException in ReportDiagnostic method. This exception would be turned into an analyzer diagnostic by the driver and reported back to the analyzer host.

Also fix a few tests that were reporting diagnostics with unsupported ID!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants