Repository navigation
Fix support for unions with null values as root component parameters - #69198
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The browser-visible cross-runtime regression still needs permanent WebAssembly E2E coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes restoration of active-null union parameters when activating prerendered WebAssembly components.
Changes:
- Initializes fresh serializer options before union metadata inspection.
- Injects serializer options into the parameter deserializer.
- Adds focused union and null-handling tests.
File summaries
| File | Description |
|---|---|
src/Shared/Components/WebAssemblyComponentSerializationSettings.cs |
Adds an options factory for isolated runtimes and tests. |
src/Components/WebAssembly/WebAssembly/src/Prerendering/WebAssemblyComponentParameterDeserializer.cs |
Configures the resolver before detecting union metadata. |
src/Components/WebAssembly/WebAssembly/test/WebAssemblyComponentParameterDeserializerUnionTest.cs |
Tests fresh-options union restoration and null rejection. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
@oroztocil Will you be planning to get this in RC2? |
|
@Youssef1313 Yes |
Co-authored-by: Copilot <[email protected]> Copilot-Session: 25597002-a307-406a-9236-8704758d4a79
0857580 to
3b16f19
Compare
DeagleGross
left a comment
There was a problem hiding this comment.
Thanks for quick fix preparation Ondrej!
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-runtime serialization, trimming, and WebAssembly behavior warrant final human review despite comprehensive coverage.
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 0 new
- Review effort level: Balanced
| DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull | ||
| }; | ||
|
|
||
| options.MakeReadOnly(populateMissingResolver: true); |
There was a problem hiding this comment.
Is it fair to say this is the actual fix and everything else is for the sake of supporting unit tests?
There was a problem hiding this comment.
Yes. The idea is to ensure that the resolver is initialized. Code paths that do Deserialize before GetTypeInfo don't have that problem because Deserialize inits the resolver itself, but GetTypeInfo does not.
To be honest, I am not well acquainted with the area, so if you see a better fix, I would appreciate a hint.
javiercn
left a comment
There was a problem hiding this comment.
A bit extreme to have E2E tests for the null union value. Is there something that the unit tests don't cover?
@javiercn I had the same opinion so I did not include any E2E tests initially. I added them to not fight the agent instructions in the repo. If you give me the permission to ignore that, I will remove the E2E tests. |
|
/backport to release/11.0 |
|
Started backporting to |
|
@oroztocil backporting to git am output$ git cherry-pick ec33757f7346be300c356208b3ab2ab141772c2d
Auto-merging src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs
CONFLICT (content): Merge conflict in src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs
error: could not apply ec33757f73... Fix support for unions with null values as root component parameters (#69198)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Fix cold WebAssembly restoration of null union parameters
Using index info to reconstruct a base tree...
M src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs
CONFLICT (content): Merge conflict in src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Fix cold WebAssembly restoration of null union parameters
Error: The process '/usr/bin/git' failed with exit code 128 |
Fixes #68798
An interactive-root component parameter whose union active case is null could fail to restore in a fresh WebAssembly runtime. The null-value path called
GetTypeInfobefore the serializer options had a configured resolver, preventing the component from becoming interactive.Initialize the options with
MakeReadOnly(populateMissingResolver: true)before inspecting union metadata. This follows the normal System.Text.Json initialization behavior while preserving existing null handling and invalid-parameter rejection.