You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Avoid boxing allocations in dependency properties [7.1+] #12410
Hey there — just a heads-up that this issue has been quiet for over a year. If there’s no update or comment in the next 10 days, it’ll be closed automatically. Feel free to remove the stale label or drop a note to keep it open.
changed the title [-]Avoid boxing allocations in dependency properties[/-][+]Avoid boxing allocations in dependency properties [7.1+
][/+]on Aug 9, 2026
changed the title [-]Avoid boxing allocations in dependency properties [7.1+
][/-][+]Avoid boxing allocations in dependency properties [7.1+][/+]on Aug 9, 2026
Audit result: PARTIALLY DONE in feature/breakingchanges (as of 0950717a0d7).
The Uno.UI.Helpers.Boxes cache the issue asks for exists and is hand-wired into a handful of call sites, but that infrastructure predates this branch (it is already present, byte-identical, on origin/master) and covers only bool, two enums, and double?. The issue's actual ask — teach DependencyPropertyGenerator/DependencyPropertyMixinGenerator to emit boxed bool sets automatically, so every [GeneratedDependencyProperty] bool setter stops allocating — is an open, unmerged PR, not landed. Integer small-value caching is not implemented at all.
Landed
Uno.UI.Helpers.Boxes cache exists — src/Uno.UI/Helpers/Boxes.cs:9-58 defines BooleanBoxes (:11-15), VerticalAlignmentBoxes (:17-23), NullableDoubleBoxes (:25-29), StretchBoxes (:31-37), plus Box(bool) (:39), Box(VerticalAlignment) (:41-48) and Box(Stretch) (:50-57) helpers. This is the file the issue proposes, matching the static object BoxedTrue = true; pattern from the issue body almost verbatim.
Hand-wired call sites — src/Uno.UI/UI/Xaml/DependencyProperty.cs:554,558,561 boxes the default value of IsTabStopProperty; src/Uno.UI/UI/Xaml/Controls/Popup/Popup.cs:115 and src/Uno.UI/UI/Xaml/UIElement.Properties.cs:46 return Boxes.BooleanBoxes.BoxedFalse / Boxes.Box(element._isHitTestVisible) from manually-written bool DP getters; src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Properties.cs:35,56 box CanUndo/CanRedo. Only 5 files in src/Uno.UI reference Boxes. at all (grep -rl "Boxes\." src/Uno.UI src/SourceGenerators → 5 hits).
This is pre-existing, not 7.0 work — git show origin/master:src/Uno.UI/Helpers/Boxes.cs returns the identical file, so none of the above landed as part of the breaking-changes branch; it was already on the pre-7.0 baseline.
Remaining
Generator-emitted boxing for [GeneratedDependencyProperty] bool setters — the issue's core ask — is not on this branch.src/SourceGenerators/Uno.UI.SourceGenerators.Internal/DependencyObject/DependencyPropertyGenerator.cs:493,616 still emit the plain form: instance.SetValue({propertyOwnerTypeName}.{propertyName}Property, value) and SetValue({propertyName}Property, value), with no Boxes.Box(...) wrapping for bool-typed properties, and git grep -n "Boxes.Box\|Helpers.Boxes" src/SourceGenerators returns nothing. The exact fix (SetValue(XProperty, global::Uno.UI.Helpers.Boxes.Box(value)) for bool) is proposed but unmerged: perf(uno-ui): Use the cached bool boxes in generated DP setters #24242 (perf(uno-ui): Use the cached bool boxes in generated DP setters, closes Generated bool DependencyProperty setters box on every set #24241) is state: OPEN, mergedAt: null — git merge-base --is-ancestor f17201fbee2 HEAD (its head commit) → not an ancestor. DependencyPropertyMixinGenerator.cs:57 likewise still emits plain this.SetValue({dp.Name}Property, value);.
Integer small-value boxing (-1, 0, 1, 2) — not implemented.grep -rn "IntBoxes\|IntegerBoxes" across src/Uno.UI and src/SourceGenerators returns no matches; Boxes.cs has no integer box table.
Enum boxing is 2 enums, not "some enums." Only VerticalAlignmentBoxes and StretchBoxes exist; no HorizontalAlignmentBoxes, VisibilityBoxes, OrientationBoxes, etc.
FrameworkPropertyMetadata default-value boxing is not systematic. Only the one hand-coded IsTabStopProperty special case in DependencyProperty.cs:550-562 uses Boxes; there is no general mechanism routing [GeneratedDependencyProperty(DefaultValue = ...)] value-type defaults through the box cache.
The issue title carries [7.1+], i.e. explicitly deferred past 7.0 by design — its incompleteness here is expected, not a regression, and should not drive any state change.
no-repro is one of the issue's current labels, which reads oddly against a live perf-allocation report; that label choice is outside the scope of this audit.
Activity
Youssef1313 commentedon May 24, 2023
@jeromelaban Thoughts on this?
jeromelaban commentedon May 24, 2023
It's an optimization that's used in WPF, so it must make sense to use :)
github-actions commentedon Aug 9, 2025
Hey there — just a heads-up that this issue has been quiet for over a year. If there’s no update or comment in the next 10 days, it’ll be closed automatically. Feel free to remove the stale label or drop a note to keep it open.
MartinZikmund commentedon Aug 11, 2025
Still relevant
[-]Avoid boxing allocations in dependency properties[/-][+]Avoid boxing allocations in dependency properties [7.1+ ][/+][-]Avoid boxing allocations in dependency properties [7.1+ ][/-][+]Avoid boxing allocations in dependency properties [7.1+][/+]MartinZikmund commentedon Sep 2, 2026
Audit result: PARTIALLY DONE in
feature/breakingchanges(as of0950717a0d7).The
Uno.UI.Helpers.Boxescache the issue asks for exists and is hand-wired into a handful of call sites, but that infrastructure predates this branch (it is already present, byte-identical, onorigin/master) and covers onlybool, two enums, anddouble?. The issue's actual ask — teachDependencyPropertyGenerator/DependencyPropertyMixinGeneratorto emit boxedboolsets automatically, so every[GeneratedDependencyProperty] boolsetter stops allocating — is an open, unmerged PR, not landed. Integer small-value caching is not implemented at all.Landed
Uno.UI.Helpers.Boxescache exists —src/Uno.UI/Helpers/Boxes.cs:9-58definesBooleanBoxes(:11-15),VerticalAlignmentBoxes(:17-23),NullableDoubleBoxes(:25-29),StretchBoxes(:31-37), plusBox(bool)(:39),Box(VerticalAlignment)(:41-48) andBox(Stretch)(:50-57) helpers. This is the file the issue proposes, matching thestatic object BoxedTrue = true;pattern from the issue body almost verbatim.src/Uno.UI/UI/Xaml/DependencyProperty.cs:554,558,561boxes the default value ofIsTabStopProperty;src/Uno.UI/UI/Xaml/Controls/Popup/Popup.cs:115andsrc/Uno.UI/UI/Xaml/UIElement.Properties.cs:46returnBoxes.BooleanBoxes.BoxedFalse/Boxes.Box(element._isHitTestVisible)from manually-writtenboolDP getters;src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Properties.cs:35,56boxCanUndo/CanRedo. Only 5 files insrc/Uno.UIreferenceBoxes.at all (grep -rl "Boxes\." src/Uno.UI src/SourceGenerators→ 5 hits).git show origin/master:src/Uno.UI/Helpers/Boxes.csreturns the identical file, so none of the above landed as part of the breaking-changes branch; it was already on the pre-7.0 baseline.Remaining
[GeneratedDependencyProperty] boolsetters — the issue's core ask — is not on this branch.src/SourceGenerators/Uno.UI.SourceGenerators.Internal/DependencyObject/DependencyPropertyGenerator.cs:493,616still emit the plain form:instance.SetValue({propertyOwnerTypeName}.{propertyName}Property, value)andSetValue({propertyName}Property, value), with noBoxes.Box(...)wrapping forbool-typed properties, andgit grep -n "Boxes.Box\|Helpers.Boxes" src/SourceGeneratorsreturns nothing. The exact fix (SetValue(XProperty, global::Uno.UI.Helpers.Boxes.Box(value))forbool) is proposed but unmerged: perf(uno-ui): Use the cached bool boxes in generated DP setters #24242 (perf(uno-ui): Use the cached bool boxes in generated DP setters, closes Generated bool DependencyProperty setters box on every set #24241) isstate: OPEN,mergedAt: null—git merge-base --is-ancestor f17201fbee2 HEAD(its head commit) → not an ancestor.DependencyPropertyMixinGenerator.cs:57likewise still emits plainthis.SetValue({dp.Name}Property, value);.-1, 0, 1, 2) — not implemented.grep -rn "IntBoxes\|IntegerBoxes"acrosssrc/Uno.UIandsrc/SourceGeneratorsreturns no matches;Boxes.cshas no integer box table.VerticalAlignmentBoxesandStretchBoxesexist; noHorizontalAlignmentBoxes,VisibilityBoxes,OrientationBoxes, etc.FrameworkPropertyMetadatadefault-value boxing is not systematic. Only the one hand-codedIsTabStopPropertyspecial case inDependencyProperty.cs:550-562usesBoxes; there is no general mechanism routing[GeneratedDependencyProperty(DefaultValue = ...)]value-type defaults through the box cache.gh pr view 12677—closes #12410, basemaster, opened years ago, stillstate: OPEN, unmerged — superseded in practice by the newer, narrower perf(uno-ui): Use the cached bool boxes in generated DP setters #24242/Generated bool DependencyProperty setters box on every set #24241 pair, which is itself still open.Caveats (not blocking)
[7.1+], i.e. explicitly deferred past 7.0 by design — its incompleteness here is expected, not a regression, and should not drive any state change.no-reprois one of the issue's current labels, which reads oddly against a live perf-allocation report; that label choice is outside the scope of this audit.SetValueon aboolDP) and reports golden/runtime-test results, so the fix is implementation-ready — it simply hasn't merged.Audit is code inspection against the branch worktree; no build or runtime validation was performed.