Skip to content

refactor: Register DependencyObject.Name without the holder - #25214

Open
MartinZikmund wants to merge 2 commits into
dev/mazi/flyout-owner-name-automationidfrom
dev/mazi/dp-storage-order-independent
Open

MartinZikmund wants to merge 2 commits into
dev/mazi/flyout-owner-name-automationidfrom
dev/mazi/dp-storage-order-independent

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: part of #21129

Note

Stacked on #25308 (base branch dev/mazi/flyout-owner-name-automationid, GitHub stack #24389). The diff shows only this PR's commits.

Stack, bottom to top (#23935 has merged, so #25307 now targets master):

  1. fix: Resolve FindName through the XAML namescope #25307 FindName / XAML namescope fixes
  2. fix: Declare Name on DependencyObject like WinUI #25184 DependencyObject-owned NameProperty
  3. fix(a11y): Use owning flyout name for presenter AutomationId #25308 flyout owner-name AutomationId
  4. This PR: register DependencyObject.Name without the holder

Restacked on master c00f09910a9. #25047's four storage commits, which this PR used to carry verbatim, are in master now and dropped out. The registration-order tests moved to their own PR against master, #26284.

PR Type:

🔄 Refactoring (no functional changes, no api changes)

What changed? 🚀

#25184 declares Name on DependencyObject like WinUI. With the old bucketed DP storage, registering it plainly cost +128 B per x:Name, because Name landed in a 16-slot bucket FrameworkElements otherwise never touch. So #25184 added a NamePropertyHolder to delay the registration until FrameworkElement's static initializer ran. That is fragile: anything that touches the property before FE's cctor (a named brush in App.xaml, say) silently brings the cost back, and static-init order across partial files isn't defined.

#25047 (now in master) made DP storage cost depend only on how many properties an object holds, not on registration order. #26284 adds the tests that pin that down. With that in place, the holder has no job left:

  1. refactor: Register DO Name without the holder: DependencyObject.NameProperty is a plain { get; } = DependencyProperty.Register(...), and FrameworkElement.NameProperty forwards to it.
  2. refactor: Drop the Name owner check in DP lookups: undoes the guard fix: Declare Name on DependencyObject like WinUI #25184 added in perf: Skip the Name holder in other DP lookups, which only kept other lookups from registering Name ahead of FrameworkElement's statics.

No behavior change. Storage coverage for Name is master's When_Border_Is_Created_Then_Storage_Fits_Its_Properties (sets Name) plus #26284's registration-order test. A dedicated "Name costs like any other property" test didn't discriminate (it passed on the old bucket storage too), so I didn't add one.

Measured: the holder is no longer needed

Arms, each a Release build of Uno.UI + headless Skia host, net10.0, same harness source:

Allocation: bytes allocated on the UI thread (GC.GetAllocatedBytesForCurrentThread()), after a warm-up of the same action. 3 alternating launches per arm, every row identical across launches (spread ≤ 0.5 B); a null arm (byte-identical copy of B in another directory) matched B exactly.

Workload B master D holder C this PR C − D
new Border() 1,544 1,544 1,544 0
new Border { Name } 1,800 1,800 1,800 0
new SolidColorBrush() 368 368 368 0
SolidColorBrush + Name throws¹ 560 560 0
10k Borders in tree, per Border 44,234 44,234 44,234 0
10k named Borders in tree, per Border 44,425 44,425 44,425 0
10k templated Fluent Buttons in tree, per Button 150,467 151,164 151,164 0
300-brush ResourceDictionary in code 210,568 210,568 210,568 0
same, every brush named throws¹ 229,768 229,768 0
300-brush ResourceDictionary via XamlReader 1,264,540 1,267,386 1,267,386 0
same, every brush with x:Name 1,713,112 1,635,037 1,635,037 0

¹ On master, setting FrameworkElement.NameProperty on a brush throws (NullReferenceException in the name backing-field callback); #25184 fixes that.

C and D are byte-identical on every workload, so dropping the holder costs nothing. The B → D differences come from #25184 itself, not this PR: +696 B per templated Button (+0.46%) and +2,846 B per 300-brush XAML load (+0.2%), against −78,075 B (−4.6%) for the x:Named dictionary.

CPU: thread cycles per op (QueryThreadCycleTime) on the UI thread, median of 7 in-process reps after a warm-up, 9 alternating launches per arm (DOTNET_TieredCompilation=0). Sweeps call GetValue over every public DP on the type's hierarchy plus 12 common attached ones (94 / 123 / 114 DPs). Cells: median of the 9 launches [min–max].

cycles/op B master B null copy D holder C this PR Verdict
Border, get set property 33.1 [27.5–37.2] 33.7 [27.7–37.6] 30.4 [29.0–35.9] 30.1 [29.0–35.7] no change
Border, get unset property 52.1 [43.6–63.7] 52.2 [44.4–60.4] 47.9 [45.7–59.9] 48.3 [46.3–58.9] no change
Border, get Name 33.5 [27.9–39.4] 34.6 [27.5–37.7] 30.7 [29.1–36.1] 27.7 [26.9–34.8] no change
Button, get unset property 52.8 [44.1–62.7] 53.4 [44.7–65.5] 50.2 [48.8–61.0] 47.3 [45.6–60.5] no change
TextBlock, get set property 36.0 [30.5–42.3] 38.0 [29.6–43.1] 28.3 [26.8–33.5] 27.8 [26.8–34.6] no change
Border sweep (94 DPs) 71.6 [54.1–81.9] 75.4 [54.9–94.6] 59.6 [56.5–82.6] 58.9 [55.6–84.0] no change
Button sweep (123 DPs) 63.9 [53.3–77.6] 65.2 [53.5–83.0] 57.6 [54.8–75.8] 59.4 [55.7–76.8] no change
TextBlock sweep (114 DPs) 74.9 [57.1–83.6] 61.4 [55.7–91.8] 60.4 [56.6–84.2] 61.8 [56.8–81.0] no change
Border SetValue (Tag) 331.0 [267.0–366.8] 296.8 [267.0–381.9] 290.5 [267.5–360.5] 291.2 [279.1–351.7] no change

Two byte-identical builds (B vs its null copy) differ by up to 22% on a median, and every cross-arm range overlaps, so none of these CPU deltas is a claim. C vs D, the comparison this PR is about, is within 3 cycles everywhere.

Validation

  • Compile: Uno.UI + Uno.UI.UnitTests at this PR's tip (net10.0, UnoFastDevBuild); Release builds of Uno.UI + headless runtime at this tip and at fix: Declare Name on DependencyObject like WinUI #25184's restacked tip.
  • Runtime (unit tests): Uno.UI.UnitTests at this tip: 4,521 run, 4,486 passed, 23 skipped, 12 failed, all 12 the known timezone-dependent When_Gregorian_FixedDate* tests.
  • Runtime tests (Skia Desktop) were not re-run after the restack.

PR Checklist ✅

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings October 11, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added area/code-generation Categorizes an issue or PR as relevant to code generation area/automation Categorizes an issue or PR as relevant to project automation kind/documentation labels Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 22s —— View job


Review of #25214

Verdict: ship (0 blocking, 1 minor, 0 nits beyond that).

  • Code review (inspection only): DependencyPropertyDetailsCollection is correct. The capacity is a power of two and the table is kept at most half full, so every probe loop terminates. Add grows before inserting. Grow rehashes from the stored UniqueId. The shared _noEntries array is never written, because the first Add always grows. NameProperty as a plain registered DP removes the static-init-order fragility.
  • Minor: one inline comment on iteration order and the staleness of the GetAllDetails() snapshot during the Enter/Leave/theme walks.
  • Compile and runtime: I did not build or run anything. The numbers in the PR description (allocations, cycles, 736 runtime tests, the 4,319 unit tests) are the author's and I did not reproduce them.
  • Conventions: commits follow Conventional Commits. I saw no event Action, no skipped tests, and no Generated/ edits in what I read. I read only the core files (DependencyPropertyDetailsCollection.cs, DependencyObject.Name.cs and the walk call sites). I did not review the XAML generator, VisualState* or the runtime and unit test files in detail.
  • Cross-cutting: the docs checklist item is unticked, but migrating-to-uno-7.md is touched. Note also that the PR carries fix: Declare Name on DependencyObject like WinUI #25184's and perf: Size DependencyProperty storage to the properties set #25047's commits until they land, so reviewers should diff against those.

/// Returns the backing table: sparse, in hash order (not registration order), and a snapshot that may
/// or may not reflect properties added while it is being walked.
/// </summary>
internal DependencyPropertyDetails?[] GetAllDetails() => _entries;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor (non-blocking): GetAllDetails() returns the live table, and the Enter/Leave and theme-update walks (DependencyObject.PropertySystem.mux.cs:56,127, DependencyObject.Theming.cs:717) call GetValue, which can create details, inside the loop. If that triggers Grow(), the walk keeps reading the old array, so properties added mid-walk are skipped. Before, they would have been visited. The doc comment already says this may happen, and it was true of the bucket storage too. Still, the enter/leave walks now visit properties in hash order, not registration order. WinUI walks them in field order, so any enter-order-sensitive logic (e.g. the theme-before-children comment at PropertySystem.mux.cs:61) is only protected by the tests in this PR. Consider one runtime test that asserts enter order for a DO that holds both a collection and a child DO.

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund MartinZikmund added the 7.0 PRs only. For issues, use the Release field. label Oct 11, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 238895 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • DisplayInformation.png-dark
    • DropDownButtonPage.png-dark
    • DynamicFont.png-dark
    • DynamicFont.png
    • Examples.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
  • skia-windows-screenshots: 2458 changed over 2486

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • ApplicationViewMode.png
    • AppWindowClosing.png
    • AppWindowTitleBar Properties.png-dark
    • ArcSegment.png-dark
    • AuthenticationBroker_Cancel.png-dark
    • AutoBorderStretchwithrightmargin.png-dark
    • AutomationProperties_Landmark.png
    • AutoSizedTopLeft.png
    • AutoSuggestBoxChosenSuggestion.png-dark
    • AutoSuggestBox_Reason.png-dark
    • AutoSuggestBox_Reason.png
    • BasicAutoSuggestBox.png-dark
    • BasicAutoSuggestBox.png
    • BasicThemeResources.png-dark
    • BasicThemeResources.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
    • BorderTopwithmargins.png-dark
    • BorderTopwithmargins.png

@unodevops

Copy link
Copy Markdown
Contributor

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

Copilot AI balanced review requested due to automatic review settings October 11, 2026 20:19
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/dp-storage-order-independent branch from eb2b871 to e159388 Compare October 11, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform area/skia ✏️ Categorizes an issue or PR as relevant to Skia area/build Categorizes an issue or PR as relevant to build infrastructure labels Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 16s —— View job


Review of #25214

Verdict: ship. 0 blocking, 0 major, 1 minor (already raised by the earlier review, so no new inline comment).

  • Code review (inspection only): I re-read DependencyPropertyDetailsCollection.cs.
    • The open-addressed table terminates on every probe. Capacity is a power of two and the load stays at or below 50%.
    • _noEntries has length 1, so mask 0 and a miss returns null without a length check. It is never written, because Add grows first.
    • Grow rehashes from UniqueId.
    • CloneToForHotReload reads this and writes other, so the table can't be mutated while it is being iterated.
  • Minor, still open: GetAllDetails() now iterates in hash order and returns a snapshot. A walk that creates details can miss properties added after a Grow(). The doc comment covers this. An Enter/Leave order test with a collection and a child DO would pin the behaviour.
  • Not verified: I did not build or run anything. The numbers in the description are the author's. The checkout is shallow (no merge base with origin/master), so I couldn't diff the full PR. The changed-file list in the context is mostly mobile accessibility work from the stacked branches, not the storage change.
  • Process: CI build 238895 failed and shows large screenshot diffs: 118 on Linux and 2,458 on Windows. The Windows count is near-total, which looks like an environment or baseline problem rather than this change. Please confirm that before merging. The docs checklist item is unticked, though migrating-to-uno-7.md is touched.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 20:49
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/dp-storage-order-independent branch from e159388 to bf49253 Compare October 11, 2026 20:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI balanced review requested due to automatic review settings October 11, 2026 21:01
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/dp-storage-order-independent branch from bf49253 to b946bb2 Compare October 11, 2026 21:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 13s —— View job


Review of #25214

Verdict: ship. Blocking 0, major 0, minor 1 (already raised, so no new inline comment).

  • Code review (inspection only): I read the five files changed by the PR's own commits: DependencyPropertyDetailsCollection.cs, DependencyObject.Name.cs, DependencyProperty.cs, FrameworkElement.cs and the collection tests. The open-addressed table is sound. The capacity is a power of two and the load stays at or below 50%, so probing always terminates. Add grows before inserting, and Grow rehashes from the stored UniqueId. NameProperty is now a plain registered DP, which removes the static-init-order fragility.
  • Minor, still open: GetAllDetails() returns the live table in hash order. A walk that creates details can miss properties added after a Grow(). The doc comment now says so. A runtime test that pins Enter/Leave order for a DO holding both a collection and a child DO would still be worthwhile.
  • Convention: the new CodeQL GC.Collect() findings are in the stacked a11y tests (feat(a11y): add mobile automation support #23935), not in this PR's storage change. They should be handled there, not here.
  • Not verified: I did not build or run anything. The allocation, cycle-count and test-count numbers in the description are the author's.
  • Process:
    • CI build 238895 failed with large screenshot diffs (118 on Linux, 2,458 on Windows). The Windows count is near-total, which points to an environment or baseline problem rather than this change. Please confirm before merging.
    • The docs checklist item is unticked.
    • This PR carries the lower PRs' commits until they land, so review only the commits after the stack base.

@MartinZikmund
MartinZikmund changed the base branch from master to dev/mazi/flyout-owner-name-automationid October 11, 2026 21:01
@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI balanced review requested due to automatic review settings October 12, 2026 06:30
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/dp-storage-order-independent branch from b946bb2 to 7b2aceb Compare October 12, 2026 06:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 13s —— View job


Review of #25214

Verdict: ship. Blocking 0, major 0, minor 1 (already raised in the earlier inline review, so no new inline comment).

  • Code review (inspection only): I re-read DependencyPropertyDetailsCollection.cs.
    • The capacity is a power of two and the table stays at or below 50% full, so every probe loop terminates.
    • _noEntries has length 1, so mask 0 and a miss returns null. It is never written, because Add grows first.
    • Grow rehashes from the stored UniqueId.
    • CloneToForHotReload reads this and writes other, so the table can't be mutated while it is being iterated.
    • NameProperty as a plain registered DP removes the static-init-order fragility that the holder hid.
  • Minor, still open: GetAllDetails() iterates in hash order and returns the live table. A walk that creates details can miss properties added after a Grow(). The doc comment says so. A runtime test that pins Enter/Leave order for a DO holding both a collection and a child DO would still be worthwhile.
  • Convention: the GC.Collect() CodeQL findings are in the stacked mobile accessibility tests (feat(a11y): add mobile automation support #23935), not in this PR's storage change.
  • Process: CI build 238895 failed with 118 Linux and 2,458 Windows screenshot diffs. The Windows count is near-total, which looks like a baseline or environment problem rather than this change. Please confirm that before merging. The docs checklist item is unticked.
  • Not verified: I did not build or run anything. The allocation, cycle-count and test-count numbers are the author's.

@morning4coffe-dev morning4coffe-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified by inspection at head 7b2aceb: the storage change is identical to #25047 (the carried commits match its diff). IsNameVisibleOn keeps its truth table after dropping the owner check, because the old check only avoided forcing registration of DependencyObject.NameProperty. FrameworkElement.NameProperty is still a public static new property with the same value. WinUI parity holds for DO-level registration: WinUI treats DependencyObject_Name as a DO-level property (dxaml/xcp/components/DependencyObject/PropertySystem.cpp:2137). No _entryOffsets, _pool, or Dispose references remain.

I did not build or run anything, so this is code review by inspection only. The allocation, cycle-count and test-count numbers are the author's.

Findings, most important first:

  1. CI is red at head 7b2aceb (Azure build 238895). The Android group-3 job fails with "does not contain any results". Its retry filter names SamplesApp.Tests.Given_ShellLayout.When_Focus_Mode_Exit_Button_Idles_It_Hides_Until_Activity Cleanup | invalid-test-for-retry. That test does not exist in this tree, so the retry ran nothing. The same filter appears in #25047's build, which points to a stale failure list on the agent. PublishTestResults also reports test failures in the result files, and I could not read the names. Please rerun, or post the failing names and confirm they also fail on master.

  2. Screenshot diffs: build 238895 reports 118 changed on Linux and 2458 of 2486 on Windows. PR #25307 (base master, no storage change) shows the same counts, so this is most likely baseline drift. Please confirm against master before merge.

  3. Static initialization: DependencyObject.NameProperty is now registered in DependencyObject's type initializer, not lazily. The PR body itself notes that static init order across partial files is undefined. Please confirm that DependencyProperty.Register does not read a DependencyObject static field that could still be unset at that point. Also confirm that a lookup of Name made during that initializer cannot observe a null NameProperty. If it could, IsNameVisibleOn would return true. A short runtime check that resolves Name before any other DependencyObject member would pin this.

  4. Minor, test comments: OrderObject says "Names are of equal length, since the SetValue path also allocates by property name length in this test host". I could not find support for that claim. Either justify it or drop it. The comment in When_Property_Is_Registered_Far_From_The_Others_Then_Storage_Costs_The_Same about "an id-aligned group" is also hard to follow. Please reword both.

  5. Minor, stacking and docs: the diff includes #25047's commits, so the review scope is the three commits after the base. The docs checklist item is unticked. The file list has no docs change, so the bot comment about migrating-to-uno-7.md does not match this PR's diff.

Once the CI red state is explained and item 3 is answered, I would expect to approve.

MartinZikmund and others added 2 commits November 10, 2026 10:43
Property storage no longer depends on a property's UniqueId, so
DependencyObject_Name can register with DependencyObject's statics and
FrameworkElement.NameProperty can forward to it. A named Border still
allocates 2,000 B (master: 2,160 B).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017TzDba3gSK3uYpvLmmBmaa
Storage no longer depends on registration order, so resolving the Name
DP ahead of FrameworkElement's statics is harmless again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017TzDba3gSK3uYpvLmmBmaa
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/dp-storage-order-independent branch from 7b2aceb to ff4448c Compare November 10, 2026 10:00
Copilot AI balanced review requested due to automatic review settings November 10, 2026 10:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 17s —— View job


Review of #25214 (head after "Drop the Name owner check")

Verdict: ship. Blocking 0, major 0, minor 2.

Scope. This is a code review by inspection only. I did not build or run anything. I read the three files in this PR's own diff against the base: DependencyObject.Name.cs, DependencyProperty.cs and FrameworkElement.cs. I did not re-review the #25047 storage commits, and the test files did not appear in the changed-file list.

What I checked

  • NameProperty registration. It is now a plain { get; } = DependencyProperty.Register(...) on DependencyObject, which removes the holder and the static-init-order fragility. The metadata is unchanged: default "", null coerced to "", and the NameCache backing-field callback.
  • FrameworkElement.NameProperty. It forwards to the DependencyObject property, so it is still a public static new property with the same value.
  • IsNameVisibleOn. The truth table is unchanged. The dropped owner check was only a registration-order guard. The remaining ReferenceEquals check is now cheap, because the property is always already registered.

On the static-init question (earlier reviewer's item 3). I found no DependencyObject static that the Register call reads. I grepped the DependencyObject*.cs partials, and the only registration-time statics are NameProperty itself and the Store statics (_trace, _propertyChangedToken, the propagation lists and the args pool). The explicit static DependencyObject() at DependencyObject.Store.cs:211 is the one thing I would verify, since it is where an ordering dependency could hide. The static field initializers in the partials run before that constructor body, though not in a defined order across files. I did not read the constructor body or DependencyProperty.Register's internals, so this is not conclusive. A small runtime test that resolves Name before touching any other DependencyObject member would settle it.

Minor findings

  1. The runtime test suggested above would pin the init-order behavior. It would also guard against IsNameVisibleOn ever seeing a null NameProperty.
  2. The enter/leave hash-order test raised earlier is still open. It would be a runtime test of a DependencyObject holding both a collection and a child. I did not re-evaluate it here.

Process

  • CI build 238895 is red. The earlier review attributes the Android retry failure to a stale filter and the screenshot counts to baseline drift. I did not verify either, so please confirm against master before merging.
  • The docs checklist item is unticked. This PR's diff has no docs change.
  • The allocation, cycle-count and test-count numbers in the description are the author's, and I did not reproduce them.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 15s —— View job


Review of #25214 (latest head: the "Drop the Name holder" refactor)

Verdict: ship, with one open question. I found 0 blocking and 0 major issues, and 1 minor point (below).

Code review (inspection only). I read the three files changed by this PR's own commits: DependencyObject.Name.cs, DependencyProperty.cs and FrameworkElement.cs.

  • DependencyObject.NameProperty is now a plain { get; } = DependencyProperty.Register(...). The change callbacks are static lambdas that only touch FrameworkElement when they run, so registration itself has no dependency on FrameworkElement's statics.
  • FrameworkElement.NameProperty => DependencyObject.NameProperty returns the same instance as before, so the public surface is unchanged.
  • IsNameVisibleOn keeps its truth table. Dropping the OwnerType pre-check is safe now that storage cost no longer depends on registration order. Every lookup now reads DependencyObject.NameProperty, which forces DependencyObject's type initializer once. That is cheap.

Open question (this is the static-init point from the earlier review). I could not confirm by inspection that DependencyProperty.Register, or the DependencyProperty static constructor, never reads a DependencyObject static. If it did, NameProperty could be observed as null while DependencyObject's type initializer is running. In that case IsNameVisibleOn would take the !ReferenceEquals(...) branch and return true. A small runtime test that resolves "Name" as the first DependencyObject access in a process would settle it, though a test run in a shared host can't easily guarantee "first". Please at least confirm it by reading the code.

Minor. The earlier test-comment nits still stand: the OrderObject equal-length-names comment and the "id-aligned group" wording. I did not re-check them.

Not verified. I did not build or run anything. The allocation, cycle and test-count figures in the description are the author's.

Process.

@MartinZikmund MartinZikmund changed the title perf: Make DP storage cost independent of registration order refactor: Register DependencyObject.Name without the holder Nov 10, 2026
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 area/skia ✏️ Categorizes an issue or PR as relevant to Skia kind/documentation platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform 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.

5 participants