Repository navigation
[inflight/candidate] Fix runtime XAML trimming regression - #39328
Merged
kubaflo merged 1 commit intoOct 12, 2026
Merged
Conversation
…ng (#39185) ### Issue Details #38613 enabled trimming for `Microsoft.Maui.Controls.Xaml`. After this change, runtime-loaded XAML containing `<Label Text="{Binding Index}" />` displayed the item type name instead of the `Index` value. The app also crashes with a XAML parse exception in some scenarios. In the Sandbox sample, the item type name is displayed instead of the expected value. **Regression PR:** #38613 ### Root Cause BindingExtension is resolved dynamically when the XAML is loaded. Since there is no direct static reference to it, the linker does not know that it is required and removes it when trimming. As a result, {Binding Index} falls back to Microsoft.Maui.Controls.Binding, whose default path is ".". The complete item is assigned to Label.Text, causing the item type name to be displayed instead of the Index value. ### Description of Changes Add DynamicDependency to the reachable XamlLoader.Visit method to preserve BindingExtension during trimming: [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(BindingExtension))] This dependency is sufficient to fix the reported {Binding Index} regression. Additional DynamicDependency attributes are also added for the other built-in runtime XAML markup extensions that are resolved dynamically. This keeps the required runtime XAML types available while allowing Microsoft.Maui.Controls.Xaml to remain trimmable. The same trimming concern was already identified in the review of [PR #38613](#38613 (comment)), which recommended adding explicit dynamic dependencies/preservation for these runtime XAML extensions. However, the recommended changes were not included in PR #38613. ### Issues Fixed Fixes #39184 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="390" height="800" src="https://github.com/user-attachments/assets/89802ebb-637d-4565-9406-9b7c5fdc35c2"> | <img width="390" height="800" src="https://github.com/user-attachments/assets/d502b1bf-d966-4807-bbb2-b6894ede9593"> | --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
4 tasks
kubaflo
added a commit
that referenced
this pull request
Oct 13, 2026
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Backport of #39185 to `inflight/candidate`, intentionally targeting the SR12 staging branch rather than `main`. Fixes the documented runtime XAML regression introduced when the XAML assembly became trimmable; that introducing change is already selected in Candidate. Preserves intrinsic markup-extension members required by runtime XAML, including binding, type and array extensions, and includes the original device-test coverage. This does not duplicate Candidate test-preservation fix #38840. Production `x:Array` behavior for #38882 remains a validation target, not a claimed runtime result. Source merge: `f54a6c82b3d4a7d2fea0ac0a8a4452b464a904c2`. Backport head: `886376bb5dd163871a75ea48ecf55a6e496c9e73`. Exactly two source files; no unrelated changes. **Validation** - `git diff --binary 3d96e23 886376b | git patch-id --stable` — passed: complete source patch identity matches `b12ed79b429d491fb1761826e50ef7dc20df57a2`. - `git diff --check 3d96e23 886376b` — passed. - Local builds and device tests were not rerun for this unchanged automated replay. PR-head CI results are pending; this is not a merge-readiness verdict. No XCTest, Appium, simulator/emulator or GUI execution was performed. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #39184 in the SR12 Candidate selection. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> /cc @kubaflo @Vignesh-SF3580 Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Vignesh-SF3580 <102575140+Vignesh-SF3580@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo
added a commit
that referenced
this pull request
Oct 14, 2026
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Backport of #39185 to `inflight/candidate`, intentionally targeting the SR12 staging branch rather than `main`. Fixes the documented runtime XAML regression introduced when the XAML assembly became trimmable; that introducing change is already selected in Candidate. Preserves intrinsic markup-extension members required by runtime XAML, including binding, type and array extensions, and includes the original device-test coverage. This does not duplicate Candidate test-preservation fix #38840. Production `x:Array` behavior for #38882 remains a validation target, not a claimed runtime result. Source merge: `f54a6c82b3d4a7d2fea0ac0a8a4452b464a904c2`. Backport head: `886376bb5dd163871a75ea48ecf55a6e496c9e73`. Exactly two source files; no unrelated changes. **Validation** - `git diff --binary 3d96e23 886376b | git patch-id --stable` — passed: complete source patch identity matches `b12ed79b429d491fb1761826e50ef7dc20df57a2`. - `git diff --check 3d96e23 886376b` — passed. - Local builds and device tests were not rerun for this unchanged automated replay. PR-head CI results are pending; this is not a merge-readiness verdict. No XCTest, Appium, simulator/emulator or GUI execution was performed. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #39184 in the SR12 Candidate selection. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> /cc @kubaflo @Vignesh-SF3580 Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Vignesh-SF3580 <102575140+Vignesh-SF3580@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo
added a commit
that referenced
this pull request
Oct 18, 2026
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Backport of #39185 to `inflight/candidate`, intentionally targeting the SR12 staging branch rather than `main`. Fixes the documented runtime XAML regression introduced when the XAML assembly became trimmable; that introducing change is already selected in Candidate. Preserves intrinsic markup-extension members required by runtime XAML, including binding, type and array extensions, and includes the original device-test coverage. This does not duplicate Candidate test-preservation fix #38840. Production `x:Array` behavior for #38882 remains a validation target, not a claimed runtime result. Source merge: `f54a6c82b3d4a7d2fea0ac0a8a4452b464a904c2`. Backport head: `886376bb5dd163871a75ea48ecf55a6e496c9e73`. Exactly two source files; no unrelated changes. **Validation** - `git diff --binary 3d96e23 886376b | git patch-id --stable` — passed: complete source patch identity matches `b12ed79b429d491fb1761826e50ef7dc20df57a2`. - `git diff --check 3d96e23 886376b` — passed. - Local builds and device tests were not rerun for this unchanged automated replay. PR-head CI results are pending; this is not a merge-readiness verdict. No XCTest, Appium, simulator/emulator or GUI execution was performed. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #39184 in the SR12 Candidate selection. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> /cc @kubaflo @Vignesh-SF3580 Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Vignesh-SF3580 <102575140+Vignesh-SF3580@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
4 tasks done
2 tasks done
38 tasks done
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Backport of #39185 to
inflight/candidate, intentionally targeting the SR12 staging branch rather thanmain. Fixes the documented runtime XAML regression introduced when the XAML assembly became trimmable; that introducing change is already selected in Candidate.Preserves intrinsic markup-extension members required by runtime XAML, including binding, type and array extensions, and includes the original device-test coverage. This does not duplicate Candidate test-preservation fix #38840. Production
x:Arraybehavior for #38882 remains a validation target, not a claimed runtime result.Source merge:
f54a6c82b3d4a7d2fea0ac0a8a4452b464a904c2. Backport head:886376bb5dd163871a75ea48ecf55a6e496c9e73. Exactly two source files; no unrelated changes.Validation
git diff --binary 3d96e23006ea80f58ff2946017eb4593f63a46c6 886376bb5dd163871a75ea48ecf55a6e496c9e73 | git patch-id --stable— passed: complete source patch identity matchesb12ed79b429d491fb1761826e50ef7dc20df57a2.git diff --check 3d96e23006ea80f58ff2946017eb4593f63a46c6 886376bb5dd163871a75ea48ecf55a6e496c9e73— passed.Issues Fixed
Fixes #39184 in the SR12 Candidate selection.
/cc @kubaflo @Vignesh-SF3580