Repository navigation
ci: skip generated code when collecting coverage - #5773
Merged
Merged
Conversation
coverlet instruments the SDK assemblies again in every test host, and for each branch it rescans the whole method for sequence points. [GeneratedRegex] turns the crontab pattern into one TryMatchAtCurrentPosition method with 8,070 IL instructions, 682 branches and 1,968 sequence points, about 90% of the instruction x branch cost across Sentry.dll. That costs about 35 s of CPU per test host before any test runs. Excluding [GeneratedCode] skips the generated regex matchers and the System.Text.Json source-generated context. Hand-written code keeps the same coverage, and CodeCoverage.runsettings already excludes the same attribute for the Microsoft collector. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5773 +/- ##
=======================================
Coverage 76.12% 76.12%
=======================================
Files 528 528
Lines 19579 19579
Branches 3829 3829
=======================================
+ Hits 14904 14905 +1
+ Misses 3792 3791 -1
Partials 883 883 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ric-oliv
marked this pull request as ready for review
October 22, 2026 13:01
ric-oliv
enabled auto-merge (squash)
October 22, 2026 13:02
bitsandfoxes
approved these changes
Oct 22, 2026
Contributor
|
⏩ ⏩ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Every test host in the build workflow spends about 35 seconds before it runs a single test. That's coverlet instrumenting
Sentry.dll, and almost all of that time goes into code the regex source generator writes for us.CecilSymbolHelper.FindClosestInstructionWithSequencePoint. The cost grows with instructions × sequence points × branches.[GeneratedRegex]turns each pattern into an unrolled matcher. The crontab pattern inCrontabValidatorbecomes oneTryMatchAtCurrentPositionmethod with 8,070 IL instructions, 682 conditional branches and 1,968 sequence points. The next biggest method inSentry.dllhas 708 instructions and 62 branches.Sentry.dll, so about 90% of the instrumentation cost. I measured this on the net10.0Sentry.dlland its PDB from the packages CI built for 8333e3b.This PR passes
ExcludeByAttribute=GeneratedCodeAttributeto the coverlet collector, so it skips anything a source generator marks as generated.Locally,
Sentry.Hangfire.Testson net10.0 took 39.8 and 41.1 seconds with coverage, and 5.4 and 9.9 seconds with the exclusion. In CI, each .NET test host used to wait 15 to 53 seconds before xUnit started, while the net48 hosts waited 4 to 7.Here's the Test step on this PR, compared with the median of 35
mainPR runs since October 15:mainPRs, median.NET (win-x64).NET (linux-x64).NET (macos).NET (linux-musl-x64).NET (win-arm64).NET (linux-arm64).NET (linux-musl-arm64)mainat the base commit, run 39744888536. On win-x64 that's 70 test runs and 14,630 passed tests, on macOS it's 59 test runs and 11,451 passed tests, and nothing failed.Failed to CreateArtifact: Unable to make request: ENOTFOUND, so its numbers come from a rerun of that job. A rerun only repeats macOS and the two AOT jobs after it, so this run has no clean end-to-end time. Counting the 51 seconds before the.NETjobs started on the first attempt, it adds up to about 66.5 minutes against a median of 77.4 formain.What changes in the coverage report:
RegexGenerator.g.csfiles and theSentryJsonContext.*.g.csfiles from the System.Text.Json source generator.EmailValidator.obj/and aren't in the repo, so Codecov never counted them. With all uploads in, it shows the same 528 files and 19,579 lines asmain, at 76.12% for both, with 14,905 lines hit against 14,904.CodeCoverage.runsettingsalready excludesGeneratedCodeAttributefor the Microsoft collector, so coverlet now matches it.The same tests run, and nothing else in the workflow changes.
#skip-changelog