When using class AnalyzerTest<TVerifier> and a diagnostic is detected, the following output is written to the test log
System.InvalidOperationException
Context: Diagnostics of test state
Mismatch between number of diagnostics returned, expected "1" actual "2"
Diagnostics:
// /0/Test1.cs(7,19): info MYD1000: Lorem ipsum
VerifyCS.Diagnostic().WithSpan("/0/Test1.cs", 7, 19, 7, 30),
// /0/Test1.cs(8,19): info MYD1000: Lorem ipsum
VerifyCS.Diagnostic().WithSpan("/0/Test1.cs", 8, 19, 8, 25),
It would be most helpful if the output also printed the code where the analyzer hit.
I agree. It would be particularly nice if it was able to print out messages using the {|#0:...|} syntax in the source code, and VerifyCS.Diagnostic().WithLocation(0) as the diagnostic.
When using class
AnalyzerTest<TVerifier>
and a diagnostic is detected, the following output is written to the test logIt would be most helpful if the output also printed the code where the analyzer hit.
https://github.com/dotnet/roslyn-sdk/blob/e9aff578fa3d6d30a1e753dbaa604f87f312ebf0/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerTest%601.cs#L815