Repository navigation
[release/11.0] Fix support for unions with null values as root component parameters - #69316
Conversation
|
Hi @oroztocil. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge. To learn more about how to prepare a servicing PR click here. |
There was a problem hiding this comment.
🟢 Approval recommended
The fix is covered by unit and end-to-end tests, with no unresolved blocking issues identified.
Pull request overview
Fixes WebAssembly restoration of nullable union parameters whose value is null during interactive root component activation.
Changes:
- Initializes and injects JSON serialization options.
- Routes null-valued unions through the appropriate converter.
- Adds unit, component, and Server/WebAssembly end-to-end tests.
File summaries
| File | Summary |
|---|---|
src/Shared/Components/WebAssemblyComponentSerializationSettings.cs |
Initializes serializer options. |
src/Components/WebAssembly/WebAssembly/test/WebAssemblyComponentParameterDeserializerUnionTest.cs |
Adds union deserialization tests. |
src/Components/WebAssembly/WebAssembly/src/Prerendering/WebAssemblyComponentParameterDeserializer.cs |
Restores null-valued union parameters. |
src/Components/test/testassets/TestContentPackage/UnionParameterCounter.razor |
Adds a union parameter test component. |
src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/CallSiteInteractiveComponents.razor |
Adds union parameter scenarios and render modes. |
src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs |
Adds Server and WebAssembly end-to-end coverage. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
Hi @oroztocil. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed. |
Backport of #69198 to release/11.0
/cc @oroztocil
Fix support for unions with null values as root component parameters
Fix nullable C# union parameters in Blazor WebAssembly
Description
Blazor can render a component as HTML on the server and then activate it in the browser using WebAssembly. Activation fails when a C# union parameter is created by passing null to a nullable case type, for example
(int?)nullinunion Value(int?, string).This PR fixes parameter restoration in such cases and adds unit and end-to-end tests.
Fixes #68798
Customer Impact
.NET 11 applications using nullable C# union parameters can display the server-rendered HTML but fail to activate the component in the browser. The browser reports that the parameter value could not be parsed. Interactive Auto is also affected when it selects WebAssembly.
Regression?
This is a support gap in the new .NET 11 union functionality rather than a regression from a previously supported release.
Risk
The change is internal and does not affect public API. Tests cover null and non-null union values, ordinary null parameters, and both Server and WebAssembly render modes.
Verification
Packaging changes reviewed?
When servicing release/2.3