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

EnC workspace does not report on generators diagnostics #70863

Closed
jeromelaban opened this issue Nov 16, 2023 · 6 comments · Fixed by #75029
Closed

EnC workspace does not report on generators diagnostics #70863

jeromelaban opened this issue Nov 16, 2023 · 6 comments · Fixed by #75029

Comments

@jeromelaban
Copy link

Version Used: 4.8.0-3.final

Steps to Reproduce:

  1. dotnet new blazorwasm -o testblazor01
  2. cd testblazor01
  3. In testblazor01.csproj add the following:
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  1. Run dotnet watch
  2. In Program.cs, add the following at the end:
 public static partial class Test
 {
     [System.Runtime.InteropServices.JavaScript.JSImport("test")]
     public static partial void Test2(IDisposable test); 
 }

Diagnostic Id: None

Expected Behavior: Hot Reload fails with error SYSLIB1072: The type 'System.IDisposable' is not supported by source-generated JavaScript interop

Actual Behavior: No errors are reported.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 16, 2023
@Youssef1313
Copy link
Member

Youssef1313 commented Nov 17, 2023

cc @davidwengier / @tmat

@tmat tmat self-assigned this Nov 17, 2023
@jeromelaban
Copy link
Author

jeromelaban commented Dec 13, 2023

After investigating a bit further, when a solution change is considered by:

var newSourceGeneratedDocumentStates = await newProject.Solution.State.GetSourceGeneratedDocumentStatesAsync(newProject.State, cancellationToken).ConfigureAwait(false);

but the compilation fails in generated code, the failing compilation does not get documents or additional documents added to the list returned by PopulateChangedAndAddedDocumentsAsync. This causes the workspace update to stop and not report diagnostics here:

if (projectSummary == ProjectAnalysisSummary.NoChanges)
{
continue;
}

This still has allowed me to find that the delta generation may fail if there are duplicate files in the AdditionalDocuments list (a case not directly related to the repro at the top, but still fails without reporting why).

@arunchndr arunchndr added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 19, 2024
@tmat
Copy link
Member

tmat commented Jun 4, 2024

There might be multiple issues here. First, the diagnostic reported by source generator isn't reported in the IDE:

If you follow the above repro, but instead of dotnet-watch open the project in VS and without running it just add the Test class, the IDE does not show the diagnostics produced by the generator:
image

The error is only reported when the project is built:
image

@CyrusNajmabadi

@CyrusNajmabadi
Copy link
Member

Are generator diagnostics something we support? I'm not sure how that is supposed to flow into pull diagnostics. Do we need some other IDiagnosticSource for that?

@tmat
Copy link
Member

tmat commented Sep 5, 2024

@CyrusNajmabadi Turns out we do have GeneratorDiagnosticsPlaceholderAnalyzer that is special cased all over DiagnosticIncrementalAnalyzer to report the source generator errors :-|. I think this might just be reporting exceptions thrown by generators.

@tmat
Copy link
Member

tmat commented Sep 9, 2024

VS reports the diagnostic correctly and right away in Automatic mode. It might take a while in Balanced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants