Skip to content

feat!: remove the legacy templated-parent mechanism (BC01) - #24070

Merged
Xiaoy312 merged 27 commits into
feature/breakingchangesfrom
dev/xygu/20260812/bc01-new-templated-parent
Aug 25, 2026
Merged

Xiaoy312 merged 27 commits into
feature/breakingchangesfrom
dev/xygu/20260812/bc01-new-templated-parent

Conversation

@Xiaoy312

@Xiaoy312 Xiaoy312 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #18672

PR Type:

💬 Other... — breaking change (legacy API removal, no behavioural change intended)

What changed? 🚀

Uno carried two mechanisms for assigning a control's templated parent:

  • Legacy: an ambient TemplatedParentScope push/pop around template materialization, with the actual
    assignment happening in the DependencyObjectStore constructor of every DependencyObject.
  • New: per-member codegen that threads a TemplateMaterializationSettings through the generated
    Build/ApplyTo methods and assigns the templated parent explicitly.

The new mechanism has been the live path for XamlReader.Load since the Jan-2024 rework, but the codegen
half was dormant behind USE_NEW_TP_CODEGEN. This PR repairs the codegen path, makes it unconditional, and
removes the legacy mechanism outright — no #if, no runtime toggle.

Commits are ordered so each one builds clean and reviews independently:

Commit What
refactor(xaml) Templated-parent codegen becomes unconditional (#define + both #ifs + the #else … = false fallback all removed together); 13 generator goldens regenerated
feat! TemplatedParentScope deleted, along with the DependencyObjectStore ctor hook, ENABLE_LEGACY_TEMPLATED_PARENT_SUPPORT, ENABLE_LEGACY_DO_TP_SUPPORT, and the legacy FrameworkTemplateBuilder surface
refactor! The template factory becomes a plain System.Func<…> behind a per-file using alias — no Uno-specific delegate type remains
feat! The TP-less Func<View?> factories are removed; 120 call sites ported
feat! Builder ctors become internal, re-exposed via MarkupHelper.Create{Data,Control,ItemsPanel}Template; XamlObjectBuilder de-reflected
feat! The vestigial DependencyObject.TemplatedParent DP is removed and its 5 readers repointed
chore PackageDiffIgnore.xml entries + BC01 ticked in the rollup spec

Two side effects worth calling out as wins rather than incidental:

  • A hot-path hook is gone. The legacy assignment ran in the DependencyObjectStore constructor, i.e. on
    every DependencyObject construction, to serve a case that only applies during template materialization.
  • Reflection and a trimming hazard are gone. XamlObjectBuilder reached the template ctors via
    Activator.CreateInstance, which is why three [DynamicDependency] attributes existed. Internalizing the
    ctors let the call become a direct type switch, so the attributes were deleted rather than carried forward.

Breaking change: impact and migration

All removed API is Uno-only — none of it exists in WinUI, so no cross-platform compatibility is lost. In
each case WinUI's own surface is either unchanged or strictly closer after this PR.

Removed Migration
new DataTemplate(() => view) (also ControlTemplate, ItemsPanelTemplate) new DataTemplate(null, (_, _) => view) — or MarkupHelper.CreateDataTemplate(null, (_, _) => view) from outside the framework
FrameworkTemplateBuilder, NewFrameworkTemplateBuilder delegates Func<object?, TemplateMaterializationSettings, UIElement?>
public builder ctors on the four template types Uno.UI.Helpers.MarkupHelper.Create{Data,Control,ItemsPanel}Template(owner, factory). The parameterless ctors stay public, as in WinUI
DependencyObject.TemplatedParent / TemplatedParentProperty GetTemplatedParent(). The DP never had a working value — Inherits was commented out and nothing wrote it, so every read returned null
TemplateManager.UpdateDataTemplate(DataTemplate, Func<View?>) The surviving overload, now Func<Builder?, Builder?>
DependencyObjectStore.SetTemplatedParent(FrameworkElement?) Was a { } no-op; delete the call

The Func<View?> removal is the one with real reach (120 in-repo call sites). It is deliberate rather than
convenient: that shape structurally cannot express a templated parent, whereas the surviving ctor hands the
factory its TemplateMaterializationSettings, so an imperative template can now read
settings.TemplatedParent. Removing it converts a silent capability gap into a compile error with a
mechanical fix.

PR Checklist ✅

Validation

Labelled per the repo's evidence protocol — what was compiled vs what was actually executed.

Runtime (executed, Skia Desktop / Win32, each A/B'd against a pre-change baseline):

Suite Result
Generator goldens (Uno.UI.SourceGenerators.Tests) 480 pass / 0 fail — 59 were failing before this PR, since the goldens were never updated for the codegen repair
Uno.UI.UnitTests 4011 pass; 13 Calendar failures, byte-identical on baseline
TemplatedParentTests, Given_FrameworkTemplate(Pool), Given_XamlReader_FrameworkTemplate 26 pass / 0 fail (baseline 27, minus one duplicate test removed — see below)
The 16 imperative-template test classes 946 pass; same 2 pre-existing failures as baseline
ComboBox, SplitView, MenuFlyout, ItemsControl 83 pass / 0 fail

Full Skia Desktop suite — executed, complete run: 8075 tests · 7844 passed · 51 failed · 180
inconclusive · 536 skipped
, 46 secondary-window teardowns, zero crashes.

All 51 failures are accounted for, and none are caused by this PR:

Count Cause
39 AssemblyLoadContext — every one reports AlcApp build failed with exit code 1; these tests shell out to dotnet build a sub-app at runtime and that nested build is broken on this machine
6 Dark-mode OS. AppsUseLightTheme=0 here, and e.g. Given_Window.When_RequestedTheme_Set_Explicitly asserts Application.Current.RequestedTheme == Light, which only holds on a Light-mode host. Expected/actual are exact light↔dark counterparts (#E4000000 ↔ #FFFFFFFF)
2 DatePickerIntegrationTests — calendar/locale (same family as the 13 pre-existing Calendar unit-test failures)
4 A/B'd against an unmodified feature/breakingchanges worktree and identical there, down to the numbers: CommandBarFlyout_Leak refcount 90 vs ≤13, When_Flyout_Closed_Target_Does_Not_Hold_Flyout, Given_TextBlock.When_Inlines_Transitively_Change, DragDrop_TreeView_Reorder_Automated [Mouse]

The two leak failures were checked rather than assumed, since a templated-parent change is a plausible cause
of a flyout that will not collect. They reproduce in isolation and at baseline with byte-identical
assertion values. The generated code also cannot capture the settings: ApplyTo_* is a class-level method
that receives __settings as a parameter (GenericApply(__that, __nameScope, __settings, ApplyTo_X)), so
no closure retains a templated parent.

The A/B baseline was verified to be the legacy path, not just a second build of the same tree: SetTemplatedParent
is absent from Uno.UI.FluentTheme.v2.dll in the baseline and present in the branch build.

Compile: Uno.UI-Skia-only.slnf and SamplesApp.Skia.Generic.

Rebased again onto feature/breakingchanges at 7c55431159, which folded DependencyObjectStore into
DependencyObject (BC26) and renamed every partial this PR touches. Three conflicts, all resolved by hand:

  • DependencyObject.Store.cs — the legacy hook sat directly above upstream's new __InitializeBinder();
    only the #if block was removed, the call kept.
  • DependencyObject.cs and DependencyObject.Store.cs — this PR's side still carried __Store-delegating
    SetBinding/ResumeBindings and the old ~DependencyObjectStore()/Dispose shape, all superseded
    upstream. Dropped in favour of upstream's SetBindingInternal and ~DependencyObject().
  • TemplatedParentScope.cs — modify/delete; deletion wins. All 7 upstream referencing files are ones this PR
    already fixes.

ENABLE_LEGACY_DO_TP_SUPPORT survived the refactor with the same misleading name, still guarding the live
templated-parent storage. Only the #if/#endif lines were stripped; the four members stay.

Two PackageDiffIgnore entries were removed as dead: BC26 added catch-all
Microsoft\.UI\.Xaml\.DependencyObjectStore.* regexes that subsume them, and upstream also made
SetTemplatedParent internal, so its removal is no longer a public break.

Re-validated on the rebased tree: goldens 480/0, SamplesApp.Skia.Generic 0/0, unit tests 13
pre-existing failures
(matching this base commit exactly, measured over 17 runs — see below), legacy-symbol
grep 0 hits.

Two Given_CollectionViewSource tests were observed failing once during this work
(When_Set_As_ItemsSource_And_Current_Initially_Set and its
_With_Disabled_IsSynchronizedWithCurrentItem sibling). Measured rather than assumed:

Tree Full runs Runs with those 2 failures
feature/breakingchanges @ 7c55431159 11 0
This branch 17 1
This branch minus its TemplatedParent-DP-removal commit 1 0

Fisher's exact on 1/17 vs 0/11 is ≈1.0, so these samples cannot distinguish the two trees — they neither
implicate this PR nor establish the flake as pre-existing. The failure has only ever been reproduced on this
branch, never on feature/breakingchanges
, so I am explicitly not claiming it is pre-existing; the origin
is unattributed and worth a look. A --filter down to that class passes 16/16 every time, so it needs the full
~4052-test run, and since [assembly: DoNotParallelize] is set the nondeterminism is GC/finalizer timing
rather than a thread race — which points at the pooled-array lifetime in DependencyPropertyDetailsCollection
and ~DependencyObject() → BinderDispose(). Neither test carries [Ignore]/[GitHubWorkItem].

Previously rebased onto a6b66724f2 (23 upstream commits, including the samples folder
nesting, the PasswordBox reparent / TextBoxCore refactors, and the sync-gen parameter renames). The rebase
applied with no conflicts, and the gates were re-run on the rebased tree:

Gate Before rebase After rebase
Generator goldens 480 / 0 480 pass / 0 fail (482 total, 2 skipped)
Uno.UI.UnitTests 4011 pass, 13 pre-existing 4011 pass, same 13
TP suites 26 / 0 26 / 0
ComboBox/SplitView/MenuFlyout/ItemsControl 0 failures 70 / 0
Legacy-symbol grep 0 hits 0 hits

The 8075-test full-suite run above was executed on the pre-rebase tree; post-rebase validation is the
targeted set in this table plus a clean SamplesApp.Skia.Generic build. Full-suite coverage of the rebased
tree is this PR's CI run.

Given_FrameworkTemplate.InstancedLegacyFactory_ShouldNotLeak was removed rather than ported: it exercised
the Func<View?> ctor, and its InstancedFactory_ShouldNotLeak twin already covers the surviving one. The
pooling/identity tests were rewritten by hand rather than mechanically ported, because the pool keys on
the factory's Target/Method — converting a capturing closure into a static method group would have
silently changed pool identity and made the tests pass for the wrong reason.

Notes for reviewers

One item is open by nature of needing CI: the PackageDiffIgnore.xml entries are unverified against real
tool output, because generatepkgdiff needs a packed nupkg across every TFM including mobile, which isn't
buildable here. Entries use isRegex where the tool's metadata form (parameter names, nullable annotations)
can't be predicted. Unmatched entries are inert, so the failure mode is a red gate rather than a silent pass —
please check them against this PR's ApiDiff report.

How the full local run was obtained (relevant to anyone reproducing it): the Win32 host segfaults with
0xC0000005 in SkiaSharp.SKSurface.Dispose ← SKNativeObject.Finalize() on secondary-window teardown —
a pre-existing fault, reproduced at the unmodified base commit with a frame-for-frame identical stack, and
unrelated to this PR. The cause is a GPU-backed SKSurface finalized after a window close destroyed its
GRContext, so forcing the raster renderer (FeatureConfiguration.Rendering.UseVulkanOnWin32 = false plus
UseOpenGLOnWin32 = false) sidesteps it entirely and no test had to be disabled. That switch was local and is
not part of this PR. Two consequences worth knowing: the host dying writes no results XML, so an aborted
run resembles a clean one; and the fault cannot be localized to a test class — it needs an abandoned GPU
surface and a GC at teardown, so a clean filtered run proves nothing. Since the run was software-rendered it
is not a like-for-like substitute for CI's GPU run, particularly for pixel comparisons.

Adjacent bug found while diagnosing that, not fixed here: Win32WindowWrapper.Rendering.OpenGl.cs
reassigns _layer without disposing the previous surface, while _swapchainSurface gets a ?.Dispose() two
lines above — a leaked GPU surface of exactly the kind that produces this finalizer crash.

Also flagged deliberately:

  • Five readers of the removed DP change behaviour — they read null today and now read a real templated
    parent: ComboBox.partial.mux.cs, SplitViewPaneAutomationPeer, SplitViewLightDismissAutomationPeer,
    ItemsControlAutomationPeer, and BrowserMediaPlayerPresenterExtension (this last one gates live WASM
    media behaviour). Each may fix a latent bug or surface new behaviour; the removal is what turned them
    from silent nulls into compile errors.
  • TemplateManager.UpdateDataTemplate changes signature, not just loses an overload. It is the
    dynamic-template-update entry point, so design-time tooling needs an aligned update.
  • The pooling hole is untouched and stays open. LoadContent still branches on the hardcoded-false
    public IsPoolingEnabled, so Given_FrameworkTemplatePool.When_Recycle stays [Ignore]d (Template recycling for reworked Templated-Parent system #18317). This
    is a recorded choice, not a discovery — behaviour is unchanged, but the legacy mechanism no longer masks it.
  • src/SamplesApp/SimpleTestApp/ is a scratch canary head, deliberately outside InternalsVisibleTo so
    it proves the MarkupHelper route works from a consumer's position. It caught two errors every other
    head compiled through. It should be dropped before merge. It is also why this PR carries a
    chore: apply XAML styler commit: xaml-style-check.yml gates src/SamplesApp/**/*.xaml and fails the PR
    on drift, even though no solution builds that head.

🤖 Generated with Claude Code

@github-actions github-actions Bot added platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform area/code-generation Categorizes an issue or PR as relevant to code generation area/build Categorizes an issue or PR as relevant to build infrastructure area/automation Categorizes an issue or PR as relevant to project automation kind/documentation labels Aug 13, 2026
@Xiaoy312
Xiaoy312 force-pushed the dev/xygu/20260812/bc01-new-templated-parent branch from 54aa3e0 to 7375453 Compare August 13, 2026 18:31
@unodevops

This comment was marked as outdated.

@unodevops

This comment was marked as outdated.

@Xiaoy312

Xiaoy312 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor Author

we need to land this pr AFTER #23702 that is merged
testing water with ci first, before continuing refactor + cleanup:

  • purge SimpleTestApp from history
  • restore Builder as a named delegate, but move it under Uno.UI/somewhere namespace as public
    • MarkupHelper will be the public adapter for the internal XyzTemplate ctors
  • rename G/SetTemplatedParent2(), now that G/SetTemplatedParent freed up

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 227523 found UI Test snapshots differences: skia-linux-screenshots: 88, skia-windows-screenshots: 112

Details
  • skia-linux-screenshots: 88 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ContentControl_Inheritance.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • Examples.png
    • DoubleImageBrushInList.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageBrushLocalAsset.png
    • ImageBrush_Stretch.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Buttons.png
    • ClipboardTests.png
    • ContextRequested.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • Image_Margin_Large.png
    • ButtonClippingTestsControl.png-dark
  • skia-windows-screenshots: 112 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • EllipsemaskingEllipseGrid.png-dark
    • ContentPresenter_Template.png-dark
    • ContentPresenter_Template.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • CameraCaptureUISample.png-dark
    • CameraCaptureUISample.png
    • ContentPresenter_NativeEmbedding_Android_FillType.png
    • Examples.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImagesInlineInFlipView.png-dark
    • ImagesInlineInFlipView.png
    • ImageBrushChangingCornerRadius.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageSourceUrlMsAppDataScheme.png-dark
    • ImageSourceUrlMsAppDataScheme.png

@Xiaoy312
Xiaoy312 force-pushed the dev/xygu/20260812/bc01-new-templated-parent branch from 7375453 to 69fe16b Compare August 14, 2026 16:02
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 227732 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 124

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png
    • DropDownButtonPage.png-dark
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ContextRequested.png-dark
    • ElementLevelTheme.png-dark
    • ImageBrushInList.png-dark
    • ElementLevelTheme.png
    • ImageBrushInList.png
    • Focus_FocusVisual_Properties.png-dark
    • ContentControl_Inheritance.png
    • ExpanderColorValidationPage.png-dark
  • skia-windows-screenshots: 124 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ContentPresenter_Template.png-dark
    • ContentPresenter_Template.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ContentPresenter_NativeEmbedding_Android_FillType.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • DynamicFont.png-dark
    • DynamicFont.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageBrushLocalAsset.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 227846 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 129

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ContentControl_Inheritance.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Examples.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageBrush_Stretch.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Buttons.png
    • DropDownButtonPage.png-dark
    • Image_Margin_Large.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • CalendarView_Theming.png-dark
  • skia-windows-screenshots: 129 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Basics Pivot Test.png
    • Battery.png-dark
    • Battery.png
    • ClipboardTests.png-dark
    • Contacts_Pick.png-dark
    • Contacts_Pick.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • Dopes.png-dark
    • EllipsemaskingEllipseGrid.png-dark
    • Examples.png
    • DataTransferManager.png-dark
    • DataTransferManager.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • DynamicFont.png-dark
    • DynamicFont.png
    • ExpanderColorValidationPage.png-dark
    • EmailManagerTests.png-dark
    • EmailManagerTests.png

@Xiaoy312
Xiaoy312 force-pushed the dev/xygu/20260812/bc01-new-templated-parent branch from 601f860 to e681002 Compare August 17, 2026 19:14
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 228244 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 805

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ContextRequested.png-dark
    • ImageBrush_Stretch.png
    • Image_Margin_Large.png
    • Attributed_text_FontSize_Changing.png
    • CalendarView_Theming.png-dark
    • Buttons.png
  • skia-windows-screenshots: 805 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • Attributed_text_FontSize_Changing.png-dark
    • AutoBorderStretchwithtopmargin.png
    • AutoSuggestBox_Description.png-dark
    • BasicAutoSuggestBox.png-dark
    • Battery.png-dark
    • BorderLeftwithmargins.png
    • BorderRightwithmargins.png-dark
    • Border_AntiAlias.png-dark
    • Border_AntiAlias.png
    • Border_CornerRadius_Clipping2.png-dark
    • Border_CornerRadius_Clipping2.png
    • Button_Opacity_Automated.png-dark
    • Button_Opacity_Automated.png
    • CenteredGridinGridwithtwofixedsizechildren.png-dark
    • CenteredGridinGridwithtwofixedsizechildren.png
    • ComboBox_ItemsSource.png-dark
    • ComboBox_ItemsSource.png
    • ComboBox_SelectedIndex.png-dark
    • ComboBox_SelectedIndex.png

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 228327 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 132

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Examples.png
    • ImageBrush_Stretch.png
    • Attributed_text_FontSize_Changing.png
    • CalendarView_Theming.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DropDownButtonPage.png-dark
    • DynamicFont.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ContentControl_Inheritance.png
    • ContextRequested.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
  • skia-windows-screenshots: 132 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • BreadcrumbBarPage.png-dark
    • DataTemplate_Update_Sample.png-dark
    • DataTemplate_Update_Sample.png
    • Elevation.png-dark
    • Elevation.png
    • ElevationView_Clipping.png-dark
    • ElevationView_Clipping.png
    • Buttons.png-dark
    • Buttons.png
    • DynamicFont.png-dark
    • DynamicFont.png
    • Examples.png
    • Image_Source_Nullify.png-dark
    • Image_Stretch_Algmnt_Inf_Horizontal.png-dark
    • Image_Stretch_Algmnt_Inf_Horizontal.png
    • DisplayInformation.png-dark
    • ElevatedView_Tester.png-dark
    • ElevatedView_Tester.png
    • ImageBrush_Formats.png-dark
    • ImageBrush_Formats.png

Xiaoy312 and others added 6 commits August 18, 2026 11:17
The per-member templated-parent assignment has been dead since it was parked
behind an undefined USE_NEW_TP_CODEGEN in Aug 2024, and had drifted out of
compiling: closureName no longer exists in that scope (it is now
writer.AppliedParameterName).

It also could never have worked in a consumer app. Generated XAML compiles into
the app's own assembly, where the internal FrameworkElement/DependencyObject
SetTemplatedParent members do not resolve at all (CS1061) -- in-repo heads only
got away with it via InternalsVisibleTo. Route the emission through a new
public [EditorBrowsable(Never)] MarkupHelper.SetTemplatedParent instead, the
same escape hatch the generator already uses for SetVisualStateLazy.

The helper takes DependencyObject rather than FrameworkElement: template members
needing a templated parent include AdaptiveTrigger, VisualState and Setter.

Both changes stay inert until USE_NEW_TP_CODEGEN is defined. Towards #8339.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The templated-parent codegen emitted __settings into the generated apply block,
but under hot reload that block is a class-level method
ApplyTo_X(T __p1, Scope __that, NameScope __nameScope) with no such symbol --
so the path could only ever have compiled with UnoForceHotReloadCodeGen=false.
Since _isHotReloadEnabled defaults to _isDebug, that meant every Debug build.

Pass __settings as a fourth parameter rather than capturing it, matching why
__that and __nameScope are already passed ("to avoid closing on __that and
__namescope when running in HotReload"), with a 3-arg GenericApply overload to
carry it. Only apply blocks for DependencyObjects inside a FrameworkTemplate
take the parameter, since __settings does not exist elsewhere.

Verified on a template-heavy page: 13 emitted apply methods take __settings,
13 call sites pass it, 13 templated-parent assignments -- with hot reload at its
default. Still inert until USE_NEW_TP_CODEGEN is defined. Towards #8339.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Pairs the two toggles that activate the per-member templated-parent
assignment: the USE_NEW_TP_CODEGEN define in the generator, and
_isLegacyTemplate = false, which retires the ambient TemplatedParentScope
injection from the DependencyObjectStore ctor.

Renders 5/6 of the SimpleTestApp probe cases. The outstanding case is a
DataTemplate built imperatively through FrameworkTemplate(Func<View?>):
codegen cannot reach objects that were never declared in XAML, so those
members lose their templated parent. WinUI has no equivalent ctor.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The per-member templated-parent assignment was gated behind USE_NEW_TP_CODEGEN,
a symbol defined nowhere. Removes the define, both #if blocks, and the
#else fallback that hardcoded needsTemplatedParent to false, so the emission
is now the only code path.

Also drops the nullable annotation from the __settings parameter of the
hot-reload apply callback: generated files carry no #nullable context, so the
'?' raised CS8669 and failed the generator suite's zero-diagnostics assertion.

Regenerates the 14 affected goldens, which had been stale since the codegen
repair landed (59 of 482 generator tests were failing before this).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Deletes the ambient TemplatedParentScope and the public FrameworkTemplateBuilder
surface it existed to serve. The per-member codegen and the XamlReader path both
assign the templated parent directly, so nothing depended on the scope any more:
_isLegacyTemplate was a const false and the scope's guard only fired when true.

Both preprocessor symbols are gone. ENABLE_LEGACY_DO_TP_SUPPORT despite its name
gated the live templated-parent storage (_templatedParentWeakRef,
Get/SetTemplatedParent2), which every TemplateBinding reads through, so its
members are kept unconditionally and only the guard is removed.

Removed:
- TemplatedParentScope, and its hook in the DependencyObjectStore ctor, which ran
  on every DependencyObject construction
- public FrameworkTemplateBuilder delegate, its four ctors, and
  AdaptFrameworkTemplateBuilder
- public no-op DependencyObjectStore.SetTemplatedParent(FrameworkElement)
- DependencyObjectStore.ApplyTemplateBindings and its
  DependencyPropertyDetailsCollection counterpart, dead once the scope's only
  call site went away
- VisualState/VisualTransition.FromLegacyTemplate and ElementStub's
  _fromLegacyTemplate, reducing both EnsureMaterialized bodies to builder.Invoke()

The [DynamicDependency] trim guards in XamlObjectBuilder are kept: they protect
the surviving ctor against the reflective Activator.CreateInstance call.

BREAKING CHANGE: FrameworkTemplateBuilder and the (object, FrameworkTemplateBuilder)
ctors of FrameworkTemplate/DataTemplate/ControlTemplate/ItemsPanelTemplate are
removed, along with DependencyObjectStore.SetTemplatedParent(FrameworkElement).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Replaces the NewFrameworkTemplateBuilder delegate with System.Func behind a
per-file `using Builder = ...` alias. With the legacy FrameworkTemplateBuilder
already gone, no Uno-specific template delegate type remains: callers and
tooling see only a Func.

The alias is repeated per file because C# aliases are file-scoped and cannot
reference other aliases, so each spells out the types fully qualified.

BREAKING CHANGE: NewFrameworkTemplateBuilder is removed. The builder ctors of
FrameworkTemplate/DataTemplate/ControlTemplate/ItemsPanelTemplate and
TemplateManager.UpdateDataTemplate now take
Func<object?, TemplateMaterializationSettings, UIElement?>.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Xiaoy312 and others added 6 commits August 18, 2026 11:17
x:Load elements and VisualState content are created after the template builder
returned: they capture the materialization settings and call OnMemberCreated
later, a path the existing tests only reach through a ControlTemplate host.

Adds the DataTemplate host, the dematerialize/re-materialize round trip, a state
whose key-frame value can only resolve through the templated parent, and a state
setter whose target is itself deferred. Closing the settings right after the
builder returns turns all four red while the eager-path tests stay green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A pooled template root outlives the host that materialized it: once another host
dequeues it, every member has to point at the new templated parent. Lazily
materialized members (x:Load, VisualState) are created outside the pool's snapshot
of the template members, and the settings they capture to reach the templated
parent are fixed at materialization time.

Hosts the template on a ContentPresenter -- the only host going through the pooled
path, as Control.Template is materialized uncached -- and drives the reuse by
detaching it, asserting the root came back from the pool and was handed to the
second host before looking at any templated parent.

The three are ignored pending #18317, each failing on a distinct piece: the tracked
member snapshot is armed by the public (permanently false) IsPoolingEnabled, so
nothing is ever tracked; lazy members are absent from that snapshot once it is
armed; and a member materialized after the recycling reads its parent from the
settings captured by the host that pooled the root. Arming the snapshot alone turns
the eager-member test green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Reusing a pooled root scanned a per-template list of materialized entries, dereferencing a weak reference per element, and that list only shrank when the scavenger ran. Keying the members by the root they belong to makes the lookup a single hash probe and drops an entry with its root.

Also removes the entry's own weak reference to the root -- the key is the root -- and the now-unused template argument on TrackMaterializedTemplate.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The materialization settings allocated a GC handle per template materialization. A DependencyObject already carries a self weak reference, which also applies the native-alive check a bare WeakReference skips, so TemplatedParent now resolves through the same path as DependencyObject.GetTemplatedParent.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The settings type has no WinUI counterpart -- it exists so a template builder
can be handed its templated parent -- so it belongs next to the two other
pieces of that contract, `FrameworkTemplateBuilder` and `TemplateManager`,
rather than under `Microsoft.UI.Xaml`.

Generated XAML spells the type in three places (the `Build` entry point, each
`Build_*` member method, and the lazy-apply handler signature), so this
regenerates 14 goldens.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
XML comments cannot contain '--', so generatepkgdiff crashed while
deserializing the ignore file, before any diffing happened. Replace the
two BC01 dash separators with em dashes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@Xiaoy312
Xiaoy312 force-pushed the dev/xygu/20260812/bc01-new-templated-parent branch from 7b13145 to c9412d1 Compare August 18, 2026 15:45
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 228450 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 129

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DropDownButtonPage.png-dark
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Image_Margin_Large.png
    • Attributed_text_FontSize_Changing.png
    • ClipboardTests.png-dark
    • CalendarView_Theming.png-dark
    • ClipboardTests.png
    • Buttons.png
    • DisplayInformation.png-dark
    • ContextRequested.png-dark
    • DisplayInformation.png
    • ContentControl_Inheritance.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Examples.png
  • skia-windows-screenshots: 129 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Basics.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • Buttons.png-dark
    • Buttons.png
    • DoubleImageBrushInList.png-dark
    • EllipsemaskingEllipseGrid.png-dark
    • GeolocatorPositionChanged.png-dark
    • GeolocatorPositionChanged.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageSourceUrlMsAppDataScheme.png-dark
    • ImageSourceUrlMsAppDataScheme.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ExpanderColorValidationPage.png-dark

@Xiaoy312

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@Xiaoy312
Xiaoy312 marked this pull request as ready for review August 21, 2026 16:24
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 229269 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 178

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Examples.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ContentControl_Inheritance.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Focus_FocusVisual_Properties.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • Attributed_text_FontSize_Changing.png
    • DynamicFont.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • ContextRequested.png-dark
  • skia-windows-screenshots: 178 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Attributed_text_FontSize_Changing.png-dark
    • ClipboardTests.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • FocusManagerTest.png-dark
    • FocusManagerTest.png
    • DeferLoadStrategyWithTemplateBinding.png-dark
    • ElementLevelTheme.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • ContentPresenter_Template.png-dark
    • ContentPresenter_Template.png
    • DisplayInformation.png-dark
    • Dopes.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImagesInlineInFlipView.png-dark
    • ImagesInlineInFlipView.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 229269 has failed on Uno.UI - CI.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 228693 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 113

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ContentControl_Inheritance.png
    • DropDownButtonPage.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ContextRequested.png-dark
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ExpanderColorValidationPage.png-dark
    • ElementLevelTheme.png-dark
    • ExpanderColorValidationPage.png
    • ElementLevelTheme.png
    • DynamicFont.png
    • Focus_FocusVisual_Properties.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Image_Margin_Large.png
    • ImageBrushInList.png-dark
  • skia-windows-screenshots: 113 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ColorAnimationUsingKeyFrames_Fill.png-dark
    • Dopes.png-dark
    • EllipsemaskingEllipseGrid.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • Basics Pivot Test.png-dark
    • Buttons.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ImageBrush_Stretch.png-dark
    • ImageBrush_Stretch.png
    • ImageSourceUrlMsAppDataScheme.png-dark
    • ImageSourceUrlMsAppDataScheme.png
    • Basics Pivot Test.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ElementLevelTheme.png-dark
    • DisplayInformation.png-dark
    • DynamicFont.png-dark
    • DynamicFont.png

@Xiaoy312
Xiaoy312 enabled auto-merge August 24, 2026 16:41
@Xiaoy312
Xiaoy312 merged commit 55f41a3 into feature/breakingchanges Aug 25, 2026
68 checks passed
@Xiaoy312
Xiaoy312 deleted the dev/xygu/20260812/bc01-new-templated-parent branch August 25, 2026 06:17
Xiaoy312 added a commit that referenced this pull request Aug 25, 2026
BC01 (#24070) landed on the base while this branch was in flight, adding
two suites that host a bare ContentPresenter and read its
ContentTemplateRoot. This branch makes that property private, so the
merge broke every Build Samples App job with the same three CS1061.

A standalone presenter has no ContentControl to report to, so these read
the materialized root as the presenter's single visual child -- the same
pattern already used by the ContentControl tests here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/build Categorizes an issue or PR as relevant to build infrastructure area/code-generation Categorizes an issue or PR as relevant to code generation kind/documentation platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants