Skip to content

Keep Base64 polyfills when Microsoft.Bcl.Memory is referenced - #665

Merged
SimonCropp merged 1 commit into
mainfrom
fix/base64-polyfill-with-bcl-memory
Oct 11, 2026
Merged

SimonCropp merged 1 commit into
mainfrom
fix/base64-polyfill-with-bcl-memory

Conversation

@SimonCropp

Copy link
Copy Markdown
Owner

Bug

Base64Polyfill.cs was guarded with #if FeatureMemory && !RefsBclMemory && !NET11_0_OR_GREATER. Microsoft.Bcl.Memory supplies Base64Url, Index and Range, but it does not (and cannot) add the net11 static members to System.Buffers.Text.Base64. So referencing that package silently removed 13 polyfills (Base64.EncodeToString, EncodeToChars, DecodeFromChars, TryDecodeFromChars, GetEncodedLength, ...) with nothing replacing them. PolyfillLib references Microsoft.Bcl.Memory below net9, so the compiled library shipped without them on those targets.

The same !RefsBclMemory condition around Base64Usage in src/Consume/Consume.cs hid this: ConsumeLib compiles that file against PolyfillLib and inherits the package reference, so the usage was compiled out exactly where the API was missing.

Fix

Remove !RefsBclMemory from the Base64Polyfill.cs guard and from the Base64Usage guard in Consume.cs.

Test

These are compile-time consumers, so the coverage is compilation:

  • Consume.cs Base64Usage is now compiled by ConsumeLib / ConsumeEmbeddedLib against PolyfillLib on every target
  • ConsumeBclMemoryNoResolve/Consume.cs (source-only Polyfill plus a Microsoft.Bcl.Memory reference) now calls Base64.EncodeToString, Base64.DecodeFromChars and Base64Url.EncodeToString

Before regenerating src/Split both failed with CS0117: 'Base64' does not contain a definition for 'EncodeToString' (and the other members). After the fix ConsumeBclMemoryNoResolve, ConsumeBclMemoryExcludeCompile, ConsumeConsumeBclMemory (which builds ConsumeBclMemory), ConsumeLib, ConsumeEmbeddedLib and Consume build on all their target frameworks with 0 warnings.

@SimonCropp SimonCropp added this to the 11.4.4 milestone Oct 11, 2026
@SimonCropp
SimonCropp merged commit 159887d into main Oct 11, 2026
5 checks passed
@SimonCropp
SimonCropp deleted the fix/base64-polyfill-with-bcl-memory branch October 11, 2026 22:10
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.

1 participant