Fix FluentKeyCode serialization in AOT apps - #5188
Merged
Denis Voituron (dvoituron) merged 2 commits intoAug 22, 2026
Merged
Denis Voituron (dvoituron) merged 2 commits into
Denis Voituron (dvoituron) merged 2 commits into
Conversation
James Newton-King (JamesNK)
requested review from
Denis Voituron (dvoituron) and
Vincent Baaij (vnbaaij)
as code owners
August 22, 2026 00:10
Copilot started reviewing on behalf of
James Newton-King (JamesNK)
August 22, 2026 00:10
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an AOT serialization failure in FluentKeyCode by ensuring the ignored-keys argument passed through JS interop is a concrete KeyCode[] rather than a deferred LINQ iterator type, which System.Text.Json source generation can’t serialize in AOT scenarios.
Changes:
- Materialize
Ignore.Union(_Modifiers)viaToArray()before invokingRegisterKeyCodein JS interop. - Add a unit test asserting the JS interop ignored-keys argument is a deduplicated
KeyCode[]when modifier ignoring is enabled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Core/Components/KeyCode/FluentKeyCode.razor.cs |
Materializes the ignored-keys union to a KeyCode[] for AOT-friendly JS interop serialization. |
tests/Core/Components/KeyCode/FluentKeyCodeTests.razor |
Adds a regression test validating the interop argument type and deduplicated contents. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
Author
|
Javier Calvarro Nelson (@javiercn) FYI, this AOT serialization issue was found while running Fluent UI Blazor with AOT on .NET 11 as part of microsoft/aspire#19565. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Denis Voituron (dvoituron)
approved these changes
Aug 22, 2026
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.
Pull Request
📖 Description
FluentKeyCodepassed a deferred LINQ union as a JavaScript interop argument whenIgnoreModifierwas enabled. The resulting internal iterator type cannot be named by System.Text.Json source generation, causing serialization to fail in AOT applications.This change materializes the ignored-key union as a concrete
KeyCode[]before invoking JavaScript. It preserves the existing filtering and duplicate-removal behavior while making the argument compatible with AOT serialization.🎫 Issues
This issue was found while running Fluent UI Blazor with AOT on .NET 11 as part of microsoft/aspire#19565.
👩💻 Reviewer Notes
The behavioral change is limited to the type of the ignored-keys JavaScript interop argument. The regression test verifies that custom ignored keys and modifier keys are passed as one deduplicated
KeyCode[].No additional smoke test is required beyond the focused unit tests.
📑 Test Plan
dotnet test tests/Core/Components.Tests.csproj --configuration Debug --filter "FullyQualifiedName~FluentKeyCodeTests"(18 passed)dotnet build src/Core/Microsoft.FluentUI.AspNetCore.Components.csproj --configuration Debug(0 warnings, 0 errors)✅ Checklist
General
Component-specific
⏭ Next Steps
None.