Skip to content

[inflight/candidate] Fix runtime XAML trimming regression - #39328

Merged
kubaflo merged 1 commit into
inflight/candidatefrom
backport/pr-39185-to-inflight/candidate
Oct 12, 2026
Merged

kubaflo merged 1 commit into
inflight/candidatefrom
backport/pr-39185-to-inflight/candidate

Conversation

@github-actions

@github-actions github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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 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 3d96e23006ea80f58ff2946017eb4593f63a46c6 886376bb5dd163871a75ea48ecf55a6e496c9e73 | git patch-id --stable — passed: complete source patch identity matches b12ed79b429d491fb1761826e50ef7dc20df57a2.
  • git diff --check 3d96e23006ea80f58ff2946017eb4593f63a46c6 886376bb5dd163871a75ea48ecf55a6e496c9e73 — 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

Fixes #39184 in the SR12 Candidate selection.

/cc @kubaflo @Vignesh-SF3580

…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

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo kubaflo changed the title [inflight/candidate] [inflight-regression] Fix runtime XAML binding regression with trimming [inflight/candidate] Fix runtime XAML trimming regression Oct 12, 2026
@kubaflo
kubaflo merged commit 5f7010b into inflight/candidate Oct 12, 2026
31 of 35 checks passed
@kubaflo
kubaflo deleted the backport/pr-39185-to-inflight/candidate branch October 12, 2026 14:39
@github-actions github-actions Bot added this to the .NET 10 SR12 milestone Oct 12, 2026
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>
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants