Open AArnott opened 3 years ago
@chsienki @jasonmalinowski can you please take a look?
The behaviour seems to have changed since this was raised: errors now appear in the Errors window, but list the project file as the source, not the additional file:
Was that an error produced by an explicit build command? Or during live analysis? Thanks!
That error can be produced during live analysis.
During an explicit build, the output is the correct additional source file, as reported in the Diagnostic
object passed to ReportDiagnostic
:
Can you link us to a repro? Thanks @Code-Grump
https://github.com/Code-Grump/additional-sources-diagnostics-repro This sample produces a diagnostic for every text file added.
Version Used: VS 16.9 Preview 2 (30718.196.main)
I have a Source Generator myself that needs to show diagnostics within Additional Files. It works in the command line build, and running a build from within VS does get the diagnostic to appear in the error list, but the background compiler doesn't ever add or remove the diagnostic from the error list, so it doesn't show up until a full build, and it doesn't disappear after being resolved without another full build.
My actual repro with the line that calls ReportDiagnostic: https://github.com/dotnet/pinvoke/blob/bf31a9e6b13ea7a5f0c436705b338e8530b814dd/src/Win32.CodeGen/SourceGenerator.cs#L66