Skip to content

fix: guard allocation-free tests for net462/net472 (#217 regression) - #315

Merged
Chris-Wolfgang merged 1 commit into
vNextfrom
fix/217-net4x-build
Jul 23, 2026
Merged

fix: guard allocation-free tests for net462/net472 (#217 regression)#315
Chris-Wolfgang merged 1 commit into
vNextfrom
fix/217-net4x-build

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Summary

The allocation-free tests added in #308 (issue #217) fail to compile on net462/net472GC.GetAllocatedBytesForCurrentThread was added to .NET Framework in 4.8, not 4.6.2 as the original PR assumed. This breaks the Debug solution build on those targets (CS0117), which surfaced when running Stryker (its initial dotnet build of the solution failed).

Root cause: the original PR validated only net10.0 and net48 and missed net462/net472.

Fix: guard the suite with #if !NET462 && !NET472. It still runs on net48+ / netcoreapp3.1+ / net5.0+; the allocation behaviour under test is TFM-agnostic, so the modern targets cover it.

Validation

dotnet build -c Debug now succeeds on net462, net472, net48, and net10.0 (previously net462/net472 errored).

Refs #217 (fixes a regression from #308).

GC.GetAllocatedBytesForCurrentThread was added to .NET Framework in 4.8, so
AllocationFreeTests failed to compile on the net462/net472 targets (CS0117),
breaking the Debug solution build. The original PR only validated net10.0 and
net48 and missed the older framework targets.

Guards the suite with `#if !NET462 && !NET472` — it still runs on net48+ /
netcoreapp3.1+ / net5.0+, which is sufficient since the allocation behaviour under
test is TFM-agnostic. Verified building net462/net472/net48/net10.0.

Refs #217

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 23, 2026 02:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants