C#: Invoke the extractor after the compiler to ensure that source generators have been executed. #20933
+6
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR, we modify the tracer to consistently run the extractor after the compiler call (which it already does in some cases), ensuring that all source generators have been executed.
This change addresses a breaking change in how .NET invokes the compiler in .NET 10 and beyond (details available here). Without this modification to the remaining patterns in the tracer, extraction of generated code will be broken in .NET 10+ (and is already broken in some cases for earlier .NET versions).
Two DCA experiments indicate this change is sound:
Autobuild suite: Shows an increase in extracted files for 13 projects and approximately 2,000 new alerts, with roughly 20 alerts removed. Spot-checking indicates that only projects with changed file extraction count have altered alert counts. Notably, all compilation errors for the project
Corona-Studio/ProjBobcathave been resolved—this project also accounts for the 20 removedcs/useless-assignment-to-local alerts(explained by successful compilation).Nightly suite: Exhibits similar patterns to the autobuild experiment. Significantly, all compilation errors for ASP.NET Core have been eliminated. These errors were likely introduced when the SHA was updated to an ASP.NET version compiled with .NET 10.
Neither experiment showed performance regressions (with one exception in the nightly suite—however, this project's extracted file count tripled due to generated source files, which explains the regression).