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

AnalyzerTest`1.FormatDiagnostics formatting #1169

Open
rjmurillo opened this issue Jul 9, 2024 · 1 comment · May be fixed by #1178
Open

AnalyzerTest`1.FormatDiagnostics formatting #1169

rjmurillo opened this issue Jul 9, 2024 · 1 comment · May be fixed by #1178
Labels
Area-MS.CA.Testing Microsoft.CodeAnalysis.Testing help wanted

Comments

@rjmurillo
Copy link

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.

private static string FormatDiagnostics(ImmutableArray<DiagnosticAnalyzer> analyzers, string defaultFilePath, params Diagnostic[] diagnostics)

@sharwell
Copy link
Member

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.

@sharwell sharwell added help wanted Area-MS.CA.Testing Microsoft.CodeAnalysis.Testing labels Jul 22, 2024
@MattFromRVA MattFromRVA linked a pull request Aug 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-MS.CA.Testing Microsoft.CodeAnalysis.Testing help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants