Fix trim/AOT safety for custom event argument deserialization in Blazor - #68113
Open
NanthiniMahalingam wants to merge 4 commits into
Open
Fix trim/AOT safety for custom event argument deserialization in Blazor#68113NanthiniMahalingam wants to merge 4 commits into
NanthiniMahalingam wants to merge 4 commits into
Conversation
Contributor
|
Thanks for your PR, @NanthiniMahalingam. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a trimming/AOT reliability issue in Blazor’s custom browser-event argument deserialization by ensuring the event-args Type carries the correct linker annotations and by switching the deserialization path to the JsonTypeInfo-based API.
Changes:
- Propagates
DynamicallyAccessedMembers(JsonSerialized)throughEventHandlerAttribute,Renderer.GetEventArgsType, andEventArgsTypeCache.GetEventArgsTypeso JSON-required members aren’t trimmed away. - Updates
WebEventData.ParseEventArgsJsonto deserialize viaJsonSerializerOptions.GetTypeInfo(...)+JsonSerializer.Deserialize(..., JsonTypeInfo)and removes the previous IL2026 suppression. - Adds coverage: a focused unit test for the custom-event deserialization path and an E2E regression test validating behavior in trimmed WASM publishes.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Components/Web/test/WebEventData/WebEventDataTest.cs | Adds unit tests for custom event-args deserialization behavior (typed handler vs parameterless). |
| src/Components/Web/src/WebEventData/WebEventData.cs | Removes the IL2026 suppression and switches to JsonTypeInfo-based deserialization for trim safety. |
| src/Components/test/E2ETest/Tests/WebAssemblyTrimmingTest.cs | Adds a trimmed-WASM regression test for custom event args surviving trimming. |
| src/Components/Components/src/RenderTree/Renderer.cs | Annotates GetEventArgsType return value to propagate linker requirements to callers. |
| src/Components/Components/src/RenderTree/EventArgsTypeCache.cs | Annotates return value and adds an IL2073 suppression for the reflection-derived parameter type. |
| src/Components/Components/src/EventHandlerAttribute.cs | Annotates eventArgsType parameters and EventArgsType property with DynamicallyAccessedMembers(JsonSerialized). |
NanthiniMahalingam
force-pushed
the
fix-45851
branch
from
August 4, 2026 12:14
1346f66 to
c1508a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug description
Root cause
Description of code changes
Fixes #45851
Output
Before changes
beforefix-45851.mp4
After changes
afterfix-45851.mp4