Repository navigation
refactor!: Remove the ContentPresenter bypass - #24187
MartinZikmund merged 8 commits into
Conversation
ContentControl skipped the ContentPresenter and parented Content directly whenever it had no Template and its default style declared none. The bypass was an Android 4.4 stack-depth workaround and had already stopped engaging: Uno.UI is Skia-only, so _IsNetStdRef is always true and the netstdref-gated default ControlTemplate was always applied. Also drops the Type-keyed HasDefaultTemplate memo (and the ALC-teardown sweep that existed only to unpin it), ButtonBase's dead RegisterEvents plumbing, and the ApplyTemplate escape hatch the bypass required. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Adds the PackageDiffIgnore entries for the ContentControl members removed with the bypass, a migration note for ContentControl subclasses that ship no ControlTemplate, and the design doc recording that the bypass was already inert before this change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
ContentTemplateRoot is WinUI API on ContentControl (get-only) and does not exist on WinUI's ContentPresenter, yet only the presenter ever had a value: ContentControl.ContentTemplateRoot returned null for every control once the bypass stopped engaging. The presenter now reports its materialized root to its templated parent, mirroring CContentPresenter, and its own property drops to private. Sibling presenters sharing a templated parent are told apart by comparing the Content dependency-property values; the CLR properties cannot be used because ContentControl.Content falls back to DataContext when the DP is unset. Fixes the SelectorItem automation-name fallback and the ItemsRepeaterScrollHost transforms, which both read the null value. Retires the sync-generator type carve-out for ContentTemplateRoot, whose native-view premise is gone. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Records the ContentPresenter bypass removal in the Phase 6 checklist with a link to its impact spec, notes that it supersedes BC36's "internal, not private" decision for ContentPresenter.ContentTemplateRoot, and adds a sequencing note against BC01 since the new report site uses GetTemplatedParent. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…v/xygu/20260824/remove-contentpresenter-bypass # Conflicts: # src/Uno.UI/UI/Xaml/Style/Generic/Generic.xaml
The base branch retired the netstdref/not_netstdref prefixes while this was in flight; the ContentControl Template setter now carries not_winappsdk, which is unconditionally included for the Skia-only Uno.UI. Same conclusion, so the Generic.xaml edit is dropped and the docs describe the current spelling. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24187/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24187/docs/index.html |
|
The build 229908 found UI Test snapshots differences: Details
|
|
Tick the box to add this pull request to the merge queue (same as
|
…contentpresenter-bypass
|
The build 230006 found UI Test snapshots differences: Details
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24187/docs/index.html |
|
|
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]>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24187/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24187/docs/index.html |
|
The build 230145 found UI Test snapshots differences: Details
|
GitHub Issue: internal —
uno-private#2163(the template allows "GitHub issue or internal"; there is no public issue for this). Noteunoplatform/uno#2163is an unrelated closed 2019 Calculator issue, socloses #2163is deliberately not used here.PR Type:
💬 Other... — breaking change: removes a Uno-only rendering shortcut and reduces public API surface on
ContentControl. (🔄 Refactoringdoesn't fit; there are API changes.)What changed? 🚀
ContentControlcarried a Uno-only shortcut —IsContentPresenterBypassEnabled— that skipped theContentPresenterand parentedContent(or the materializedContentTemplate) directly, whenever the control had noTemplateand its default style declared noTemplatesetter. Its own doc comment gave the reason: an Android 4.4 stack-depth workaround (32 KB stack, fixed by ART).The bypass was already inert — this is mostly dead-code removal
The issue reads as a behavioural fix. It isn't, and that's worth stating up front so reviewers don't go looking for a rendering change.
The default
ContentControltemplate inGeneric.xamlis gated on a conditional-XAML prefix. At the time this work started that prefix was spellednetstdref:, which reads like "reference build only". It never meant that:_IsNetStdRefwas true wheneverUnoRuntimeIdentifierwasSkiaorWebAssembly, or the TFM was plainnetX.0.Uno.UI.csprojsetsUnoRuntimeIdentifier=Skiaand targets Skia TFMs only — there is no native Android/iOSUno.UIbuild any more — so the setter was always included,HasDefaultTemplate(typeof(ContentControl))was alwaystrue, andIsContentPresenterBypassEnabledwas alwaysfalsefor a bareContentControl.An independent record of the same fact already lived in the test suite (
Given_FrameworkTemplate.cs):So padding, content alignment, the presenter layer and
templatedParentonContentTemplateroots are all unchanged — that was already the shipping behaviour.Commits
refactor!: Remove the ContentPresenter bypass— deletesIsContentPresenterBypassEnabled,UpdateContentTemplateRoot,SyncDataContext, the content-DataContext override plumbing, theImplicitTextBlockplaceholder path, and theOnLoaded/OnVisibilityChanged/OnDataContextChanged/MeasureOverrideoverrides that existed only to drive it.ContentControl.csgoes 538 → 180 lines. Also drops:Type-keyedHasDefaultTemplatelookup and the ALC-teardown sweep that only existed to unpin it (a leak and its workaround, both gone);ButtonBase.OnContentTemplateRootSet() => RegisterEvents()and thepartial void RegisterEvents()it called — dead twice over, since the hook only fired under the bypass and the partial lost its last implementation when the native Android/iOS partials were dropped;(this as ContentControl)?.Content == GetFirstChild()clause andClearContentPresenterBypass()escape hatch inFrameworkElement.ApplyTemplate, which collapses to!HasTemplateChild();chore: Register and document the bypass removal—PackageDiffIgnoreentries, a migration note inmigrating-to-uno-7.md, and the impact spec.refactor!: Report ContentTemplateRoot from ContentPresenter— see below.docs: Add #2163 to the breaking-changes rollup— checklist entry inspecs/050-breaking-changes-rollup/spec.md.docs: Follow the conditional-prefix cleanup on the base— after merging the updated base, drops the now-redundantGeneric.xamledit and re-words the docs for the current prefix spelling.test: Read a presenter's template root from the tree— see "Collision with BC01" below.Collision with BC01 (#24070)
BC01 landed on
feature/breakingchangeswhile this was in flight and was merged in here. It adds two suites —TemplatedParentTests.RecyclingandGiven_FrameworkTemplate_And_Leak— that host a bareContentPresenter(the only way to exercise the pooled-materialization path, sinceControl.Templateis materialized uncached) and read itsContentTemplateRoot. This PR makes that propertyprivate, so the merge failed everyBuild Samples Appjob with the same threeCS1061.A standalone presenter has no
ContentControlto report to, so those three sites now read the materialized root as the presenter's single visual child — the same pattern theGiven_ContentControltests in this PR already use. No production code changed.ContentTemplateRoot: one accessor, onContentControlContentTemplateRootis genuine WinUI API onContentControland does not exist on WinUI'sContentPresenter. Evidence, all local:Generated/…/ContentControl.cscarries// Skipping already declared property ContentTemplateRootand// Forced skipping of method …ContentControl.ContentTemplateRoot.get. These stubs are generated by walking the WinAppSDK reference metadata; a member absent from it produces no line at all;.getis listed — WinUI's property is read-only, so dropping Uno'sprotected setfrom the public surface is parity, not just cleanup;ContentPresenterstub contains noContentTemplateRootline whatsoever.Because the bypass never assigned it,
ContentControl.ContentTemplateRootreturnednullfor every control. The templatedContentPresenternow reports its materialized root there — mirroring WinUI'sCContentPresenterwritingContentControl::m_tpContentTemplateRoot— and the presenter's own property drops toprivate.This supersedes BC36 (#16148), which deliberately chose
internaloverprivate"because in-assembly callers read it cross-type". Those callers only existed because theContentControlaccessor was always null;spec.mdrecords the reversal.Three MUX ports read the null value and degraded silently. Two are genuine fixes (
SelectorItem's automation-name fallback,ItemsRepeaterScrollHost'sTransformToVisualagainst the scroll viewer's content root);HyperlinkButtonalready worked via an explicit// TODO Uno: … which is nullworkaround and is rewritten onto the real accessor.When a template hosts several presenters under one templated parent (ContentDialog's Title/Icon, CommandBar), the reporting one is picked by comparing the
Contentdependency-property values — the CLR properties can't be used, becauseContentControl.Content's getter falls back toDataContextwhen the DP is unset.Testing 🧪
Runtime (Skia Desktop):
Given_ContentControl+Given_ContentPresenter+Given_Control→ 301/301.Given_ItemsControl+Given_Button+Given_HyperlinkButton→ 27/27, includingWhen_HyperlinkButton_With_Implicit_Content_Should_Be_Underlined(covers the rewritten accessor) and the container-recycling tests.Given_ContentDialog17/19. The two failures (When_DefaultButton_Set/_Not_Set, foreground-colour asserts) are pre-existing — reproduced identically on a clean tree by stashing this branch and rebuilding.Unit tests: 13 failures, all the pre-existing
When_Calendartimezone set.Given_FrameworkTemplate'sMaterializedRoothelper now readsContentControl.ContentTemplateRootdirectly and passes, which is runtime proof of both the report and the clear-on-teardown path.New tests in
Given_ContentControl: the presenter is materialized for a bareContentControl;ContentTemplateRootreturns the presenter's root; it is cleared whenContentTemplateis removed.Consumer build:
SamplesApp.Skia.Genericbuilds clean (API reductions break at consumers, not definitions). Each commit verified to build standalone.Re-validated after merging the updated base (
feature/breakingchangeshad moved ~20 commits, including the conditional-prefix cleanup): build clean, unit tests back to the same 13-failure baseline.After the BC01 merge:
Given_ContentControl+Given_FrameworkTemplate_And_Leak+TemplatedParentTests→ 34/34, 3 skipped (BC01's own[Ignore]d recycling tests, Template recycling for reworked Templated-Parent system #18317). This matters beyond the compile fix: BC01 reworked the templated-parent mechanism this feature rides on, andContentTemplateRootis reported from inside the materialization path — the green run is what proves the report still fires.✅ WinAppSDK Sync Generator Check passed on CI, confirming that retiring the
ContentTemplateRoottype carve-out inSymbolMatchingHelpersleavessrc/Uno.UI/Generated/**byte-identical. (It could not be run locally —build/run-api-sync-tool.cmddies onNETSDK1045fornet11.0plus a missingtvosworkload.)PR Checklist ✅
Screenshots Compare Test Runresults.Breaking changes — impact and migration
Targeting the 7.0 breaking-changes branch; registered in
build/PackageDiffIgnore.xmlanddoc/articles/migrating-to-uno-7.md.ContentControlsubclass that sets its ownDefaultStyleKeyand provides noTemplatein its default style no longer rendersContent— it renders nothing, as on WinUI. Migration: give it a default style with aTemplate, or leaveDefaultStyleKeyalone so it inherits theContentControldefault template. In-framework, only the unusedDatePickerSelector/TimePickerSelectorare in that shape. DefaultContentControlusage is unaffected.ContentControl.ContentTemplateRootloses itsprotected set(WinUI's property is get-only);UpdateContentTemplateRoot(),SyncDataContext()and theOnVisibilityChanged/OnDataContextChanged/MeasureOverrideoverrides are removed fromContentControl.ContentControl.ContentTemplateRootgoes from always-nullto populated. Code that (deliberately or not) relied on thenullwill now see the template root.Out of scope — follow-ups
HorizontalContentAlignment="Left"/VerticalContentAlignment="Top"while BC45 movedControl's DP defaults toCenter/Center. Both are live today and they disagree once the style applies — a pre-existing divergence. It needs a native-WinUI measurement and its own item; bundling a real visual change into a dead-code removal would be wrong.ItemsControl.GetGroupHeaderContainerstill returns aContentControlwhere WinUI returns aContentPresenter. Observable viaItemContainerStyleandContainerFromItemcasts — its own breaking-change item.SymbolMatchingHelpers.ArePropertiesMatchinghas itsIsReadOnly/IsWriteOnlychecks commented out (// TODO:). That is why Uno's extraprotected seton a read-only WinUI property was never flagged — the sync generator structurally cannot catch accessor divergence.Given_Control.When_Padding_Set_In_SizeChangedcarries a stale[Ignore]reason ("ContentControl … is a superclass of UserControl on Uno" — untrue since BC14). Left alone deliberately: it applies to the WinAppSDK head only and the real reason for skipping there couldn't be determined, so inventing a new reason would be worse.🤖 Generated with Claude Code