Skip to content

Conversation

@michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Nov 28, 2025

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/ProjBobcat have been resolved—this project also accounts for the 20 removed cs/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).

@github-actions github-actions bot added the C# label Nov 28, 2025
@michaelnebel michaelnebel force-pushed the csharp/runtraceraftercompilation branch 3 times, most recently from b3e96c4 to 2bb6c63 Compare November 28, 2025 14:42
@michaelnebel michaelnebel marked this pull request as ready for review December 3, 2025 13:04
@michaelnebel michaelnebel requested a review from a team as a code owner December 3, 2025 13:04
Copilot AI review requested due to automatic review settings December 3, 2025 13:04
Copilot finished reviewing on behalf of michaelnebel December 3, 2025 13:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modifies the C# tracer configuration to invoke the extractor after compiler execution rather than before, ensuring source generators have completed before extraction begins. This change addresses a breaking change in .NET 10's compiler invocation pattern and improves extraction reliability across all .NET versions.

Key Changes:

  • Updated two CreatePatternMatcher configurations to use ORDER_AFTER instead of ORDER_BEFORE for CSC compiler patterns
  • Added change notes documenting the fix for compiler-generated file extraction

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
csharp/tools/tracing-config.lua Changed extraction order from ORDER_BEFORE to ORDER_AFTER for Windows (csc.*\.exe) and POSIX (mcs\.exe, csc\.exe, csc) compiler matchers to ensure source generators complete before extraction
csharp/ql/lib/change-notes/2025-12-03-run-tracer-after-compilation.md Added release notes documenting the fix for compiler-generated file extraction

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@michaelnebel michaelnebel force-pushed the csharp/runtraceraftercompilation branch from 9ff2a1b to a903420 Compare December 3, 2025 14:49
@michaelnebel michaelnebel requested a review from hvitved December 4, 2025 08:14
Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great detective work 🕵️

@michaelnebel michaelnebel merged commit cdd8aa4 into github:main Dec 4, 2025
29 checks passed
@michaelnebel michaelnebel deleted the csharp/runtraceraftercompilation branch December 4, 2025 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants