-
Notifications
You must be signed in to change notification settings - Fork 7
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
AnalyzerAssert.Valid: One analyzer with three diagnostics with the same id #99
Comments
Agreed the exception message should be improved. About multiple diagnostics with the same ID: |
I think it is fine to keep the check. I was just hoping that there were some guidelines - or similar - on the Net about issues such as these as I find Roslyn lacking some proper documentation. I will make all the diagnostics in NUnit.Analyzers unique (and perhaps create a PR for the exception message 😄). |
In order to use Gu.Roslyn.Asserts to make tests more succient, and also to reduce the "magic" in the tests, we need that all analyzers have unique identifers. This PR just makes all the identifers unique, in a subsequent PR we'll make use of Gu.Roslyn.Asserts. See GuOrg/Gu.Roslyn.Asserts#99 for a little context.
I was trying to make usage of this library in connection with nunit/nunit.analyzers#70, and I ran into some problems with an analyzer that has 3 diagnostics with the same id (see snippet below). I don't know if this is a "major no no" with Roslyn analyzers, but as far as I can tell most of the other analyzers have distinct ids for each diagnostic (and I think that I'm going to change the class to follow that approach). So feedback about this is much appreciated.
TestCaseUsageAnalyzer.cs
When the code fails from
AnalyzerAssert.Valid(Analyzer, testCode)
it fails with a general unspecific error message that requires one to examine the code of this project to figure out what the problem is (that the id is used as a key in a dictionary). And I think that this could be improved.If I also pass in a
DiagnosticDescriptor
, likeAnalyzerAssert.Valid(Analyzer, Analyzer.SupportedDiagnostics.First(), testCode)
, the I get the following more useful error message.The text was updated successfully, but these errors were encountered: