Skip to content

[wasm] Don't deploy the NetCoreAppMinimum BinaryFormatter copy on browser/wasi - #132475

Draft
pavelsavara wants to merge 1 commit into
dotnet:mainfrom
pavelsavara:no_BinaryFormatter_WASM
Draft

[wasm] Don't deploy the NetCoreAppMinimum BinaryFormatter copy on browser/wasi#132475
pavelsavara wants to merge 1 commit into
dotnet:mainfrom
pavelsavara:no_BinaryFormatter_WASM

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

Test-infra only. Excludes the NetCoreAppMinimum private copy of System.Runtime.Serialization.Formatters from the app closure on browser/wasi, so those apps deploy the framework build instead.

Many test projects reference the NetCoreAppMinimum build of System.Runtime.Serialization.Formatters (Private="true", SetTargetFramework=$(NetCoreAppMinimum)) to get a functional BinaryFormatter. BinaryFormatter is unsupported on browser/wasi (PlatformDetection.IsBinaryFormatterSupported is false for IsBrowser), so those tests are already skipped there and the private copy serves no purpose.

On self-contained wasm the private copy is the only Formatters deployed (it shadows the framework build). In official builds it carries AssemblyVersion=10.0.0.0 (the NetCoreAppMinimum TFM), while the test IL is compiled against the current framework reference (Version=11.0.0.0). CoreCLR's strict assembly-version binding won't bind down, so un-gated serialization-infra tests fail at load, e.g.:

System.Tests.DateTimeTests.GetObjectData_Invoke_ReturnsExpected
System.IO.FileNotFoundException : Could not load file or assembly
'System.Runtime.Serialization.Formatters, Version=11.0.0.0, ...'

Mono passes only because its loader binds by simple name (version-agnostic).

Fix

Gate the private reference to non-wasm in all affected test projects:

<ProjectReference Include="...System.Runtime.Serialization.Formatters.csproj"
                  Private="true"
                  SetTargetFramework="TargetFramework=$(NetCoreAppMinimum)"
                  Condition="'$(TargetOS)' != 'browser' and '$(TargetOS)' != 'wasi'" />

On browser/wasi the framework net11.0 build is now deployed (AssemblyVersion=11.0.0.0), which satisfies the reference and keeps SerializationInfo/FormatterConverter functional; BinaryFormatter tests remain skipped as before. No behavioral change on other platforms.

Verification

Reproduced and validated locally on CoreCLR browser-wasm (V8):

  • Before: the deployed System.Runtime.Serialization.Formatters.dll came from bin/System.Runtime.Serialization.Formatters/Release/net10.0/.
  • After: it comes from the runtime pack bin/microsoft.netcore.app.runtime.browser-wasm/Release/runtimes/browser-wasm/lib/net11.0/ (framework build).
  • System.Tests.DateTimeTests still passes (1372/1373; the 1 skip is a BinaryFormatter-gated test).

Note

This PR description was generated with the assistance of GitHub Copilot.

BinaryFormatter is unsupported on browser/wasi (PlatformDetection.IsBinaryFormatterSupported
is false), so the NetCoreAppMinimum private copy of System.Runtime.Serialization.Formatters
(referenced only for a functional BinaryFormatter) serves no purpose there. On self-contained
wasm it shadows the framework build, and its official AssemblyVersion (lower than the app's
compiled v11 reference) fails CoreCLR's strict assembly-version binding, so serialization-infra
tests such as DateTimeTests.GetObjectData fail to load Formatters. Gate the private reference to
non-wasm so the framework build is deployed on browser/wasi.
Copilot AI lite review requested due to automatic review settings August 18, 2026 16:12
@pavelsavara pavelsavara added the arch-wasm WebAssembly architecture label Aug 18, 2026
@pavelsavara pavelsavara added this to the 12.0.0 milestone Aug 18, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

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.

Pull request overview

Updates multiple library test project files to avoid deploying the NetCoreAppMinimum private copy of System.Runtime.Serialization.Formatters on browser/wasi, so those targets rely on the framework-provided assembly instead. This is a test-infra change scoped to .csproj references and is intended to prevent version-shadowing issues specific to WebAssembly deployments.

Changes:

  • Adds Condition="'$(TargetOS)' != 'browser' and '$(TargetOS)' != 'wasi'" to the System.Runtime.Serialization.Formatters ProjectReference used for NetCoreAppMinimum/BinaryFormatter scenarios.
  • Applies the same gating consistently across the affected test projects that were privately copying the NetCoreAppMinimum Formatters build.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/libraries/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/System.Text.RegularExpressions.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Security.Cryptography/tests/System.Security.Cryptography.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Runtime/tests/System.Resources.ResourceManager.Tests/System.Resources.ResourceManager.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Runtime.Serialization.Primitives/tests/System.Runtime.Serialization.Primitives.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Runtime.Serialization.Formatters/tests/System.Runtime.Serialization.Formatters.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Resources.Extensions/tests/System.Resources.Extensions.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Resources.Extensions/tests/CompatTests/System.Resources.Extensions.Compat.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/System.Resources.Extensions.BinaryFormat.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.ObjectModel/tests/System.ObjectModel.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Formats.Nrbf/tests/System.Formats.Nrbf.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Configuration.ConfigurationManager/tests/System.Configuration.ConfigurationManager.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.ComponentModel.Primitives/tests/System.ComponentModel.Primitives.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.ComponentModel.Annotations/tests/System.ComponentModel.Annotations.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Collections/tests/System.Collections.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Collections.Specialized/tests/System.Collections.Specialized.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/System.Collections.NonGeneric/tests/System.Collections.NonGeneric.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Microsoft.Extensions.Hosting.Unit.Tests.csproj Gates the NetCoreAppMinimum private Formatters copy off for browser/wasi.

@akoeplinger

Copy link
Copy Markdown
Member

I'm not sure this is correct. CoreCLR on mobile and NativeAOT also doesn't have binaryformatter and it doesn't run into this issue. We should be able to load the 10.0 version of the assembly the same way.

@pavelsavara
pavelsavara marked this pull request as draft August 19, 2026 06:13
@pavelsavara pavelsavara added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Infrastructure-libraries NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants