fix: guard allocation-free tests for net462/net472 (#217 regression) - #315
Merged
Conversation
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>
This was referenced Jul 24, 2026
This was referenced Aug 5, 2026
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.
Summary
The allocation-free tests added in #308 (issue #217) fail to compile on
net462/net472—GC.GetAllocatedBytesForCurrentThreadwas 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 initialdotnet buildof the solution failed).Root cause: the original PR validated only
net10.0andnet48and missednet462/net472.Fix: guard the suite with
#if !NET462 && !NET472. It still runs onnet48+/netcoreapp3.1+/net5.0+; the allocation behaviour under test is TFM-agnostic, so the modern targets cover it.Validation
dotnet build -c Debugnow succeeds on net462, net472, net48, and net10.0 (previously net462/net472 errored).Refs #217 (fixes a regression from #308).