[wasm] Don't deploy the NetCoreAppMinimum BinaryFormatter copy on browser/wasi - #132475
[wasm] Don't deploy the NetCoreAppMinimum BinaryFormatter copy on browser/wasi#132475pavelsavara wants to merge 1 commit into
Conversation
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.
|
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. |
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
There was a problem hiding this comment.
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 theSystem.Runtime.Serialization.FormattersProjectReferenceused forNetCoreAppMinimum/BinaryFormatter scenarios. - Applies the same gating consistently across the affected test projects that were privately copying the
NetCoreAppMinimumFormatters 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. |
|
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. |
Summary
Test-infra only. Excludes the
NetCoreAppMinimumprivate copy ofSystem.Runtime.Serialization.Formattersfrom the app closure on browser/wasi, so those apps deploy the framework build instead.Many test projects reference the
NetCoreAppMinimumbuild ofSystem.Runtime.Serialization.Formatters(Private="true",SetTargetFramework=$(NetCoreAppMinimum)) to get a functionalBinaryFormatter. BinaryFormatter is unsupported on browser/wasi (PlatformDetection.IsBinaryFormatterSupportedisfalseforIsBrowser), so those tests are already skipped there and the private copy serves no purpose.On self-contained wasm the private copy is the only
Formattersdeployed (it shadows the framework build). In official builds it carriesAssemblyVersion=10.0.0.0(theNetCoreAppMinimumTFM), 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.: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:
On browser/wasi the framework
net11.0build is now deployed (AssemblyVersion=11.0.0.0), which satisfies the reference and keepsSerializationInfo/FormatterConverterfunctional; BinaryFormatter tests remain skipped as before. No behavioral change on other platforms.Verification
Reproduced and validated locally on CoreCLR browser-wasm (V8):
System.Runtime.Serialization.Formatters.dllcame frombin/System.Runtime.Serialization.Formatters/Release/net10.0/.bin/microsoft.netcore.app.runtime.browser-wasm/Release/runtimes/browser-wasm/lib/net11.0/(framework build).System.Tests.DateTimeTestsstill passes (1372/1373; the 1 skip is a BinaryFormatter-gated test).Note
This PR description was generated with the assistance of GitHub Copilot.