cezarypiatek / RoslynTestKit

A lightweight framework for writing unit tests for Roslyn diagnostic analyzers, code fixes, refactorings and completion providers.
Other
24 stars 7 forks source link

Add NoDiagnostic with support for multiple diagnostic Ids #22

Closed gbtb closed 1 year ago

gbtb commented 1 year ago

Hello :wave:

I'm developing an analyzer which provides multiple diagnostics all related to correct usage of specific attributes on DTO classes. I have 6 diagnostics inside one analyzer which I gradually developing one by one, writing corresponding tests that confirm each diagnostic detection. At the end I'd like to make a test for a fully correct DTO declaration and confirm that no diagnostics triggered for that test case. So far I resorted to calling NoDiagnostic in a loop for each diagnostic, but it looks a little bit ugly. What do you think about adding new overloads to support that usecase?

NoDiagnostic(Document document, string[] diagnosticIds, IDiagnosticLocator locator = null);
NoDiagnostic(string code, string[] diagnosticIds);

If you don't mind, I can submit a PR :slightly_smiling_face:

cezarypiatek commented 1 year ago

Hi, I've never had such a use case, but if you think this will be useful then feel free to contribute.