Test method MyCustomDiagnosticSuppressions.Test.SA1615SuppressorTests.Should_Be_Suppressed threw exception:
System.InvalidOperationException: Mismatch between number of diagnostics returned, expected "1" actual "0"
Diagnostics:
NONE.
Stack Trace:
DefaultVerifier.Equal[T](T expected, T actual, String message)
AnalyzerTest`1.VerifyDiagnosticResults(IEnumerable`1 actualResults, ImmutableArray`1 analyzers, DiagnosticResult[] expectedResults, IVerifier verifier)
AnalyzerTest`1.VerifyDiagnosticsAsync(EvaluatedProjectState primaryProject, ImmutableArray`1 additionalProjects, DiagnosticResult[] expected, IVerifier verifier, CancellationToken cancellationToken)
AnalyzerTest`1.RunImplAsync(CancellationToken cancellationToken)
AnalyzerTest`1.RunAsync(CancellationToken cancellationToken)
SA1615SuppressorTests.Should_Be_Suppressed() line 34
I've written a diagnostic suppressor that suppresses SA1615 from the StyleCop.Analyzers NuGet package.
I've also written a unit test for the suppressor, but I can't get the diagnostic to trigger in it. I get
Mismatch between number of diagnostics returned, expected "1" actual "0".If I copy the code to a new project with the NuGet package installed, the diagnostic is reported.
Suppressor code
Unit test code
Unit test output
Screenshot showing SA1615 for the test code