Skip to content

Do not polyfill File.OpenNullHandle on net11 - #650

Merged
SimonCropp merged 3 commits into
mainfrom
fix/opennullhandle-net11
Oct 11, 2026
Merged

SimonCropp merged 3 commits into
mainfrom
fix/opennullhandle-net11

Conversation

@SimonCropp

Copy link
Copy Markdown
Owner

Bug

File.OpenNullHandle was guarded by #if !NET12_0_OR_GREATER, but the method ships in net11 (present in the Microsoft.NETCore.App.Ref 11.0.0-rc.1 pack pinned by global.json, absent from 10.0.12). On net11 the polyfill was dead code and counted as a polyfilled API. Consume.cs hid this by only calling it under #if !NET11_0_OR_GREATER.

Fix

  • Guard changed to #if !NET11_0_OR_GREATER (the block also holds HardLinkHelper/NullDeviceHelper, which are only needed below net11).
  • Consume.cs now calls File.OpenNullHandle() on every TFM.

Coverage

  • New FilePolyfillTests.OpenNullHandle_NotPolyfilledWhereBclHasIt asserts via reflection that Polyfills.Polyfill does not declare OpenNullHandle when System.IO.File does. Fails on net11.0 before the fix; passes on net48, net10.0 and net11.0 after.
  • The existing OpenNullHandle test exercises the polyfill below net11 and the BCL on net11.
  • Consume built for net461, net10.0 and net11.0.

Split files and API counts regenerated (net11.0: 58 -> 57; src/Split/net11.0/FilePolyfill.cs is now empty and removed).

@SimonCropp SimonCropp added this to the 11.4.4 milestone Oct 11, 2026
@SimonCropp
SimonCropp force-pushed the fix/opennullhandle-net11 branch from 3c2c67d to 0093388 Compare October 11, 2026 22:18
@SimonCropp
SimonCropp merged commit e102f28 into main Oct 11, 2026
@SimonCropp
SimonCropp deleted the fix/opennullhandle-net11 branch October 11, 2026 22:33
This was referenced Oct 12, 2026
This was referenced Oct 13, 2026
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