Skip to content

feat!: Make DependencyObject a class instead of an interface - #23537

Merged
MartinZikmund merged 9 commits into
feature/breakingchangesfrom
dev/mazi/do-class
Jul 8, 2026
Merged

MartinZikmund merged 9 commits into
feature/breakingchangesfrom
dev/mazi/do-class

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: Closes #17099 · Closes unoplatform/uno-private#2055 — DependencyObject should be a class. Part of the breaking-changes rollup (epic #8339).

PR Type:

🔄 Refactoring · 💬 Breaking change (feat!)

What changed? 🚀

On the historical native targets, Microsoft.UI.Xaml.DependencyObject was a C# interface whose implementation was injected per-type by DependencyObjectGenerator — a workaround forced by UIElement having to inherit native view base classes (Android View, iOS UIView). With the native targets dropped (#23470) that constraint is gone, so DependencyObject becomes a normal base class, exactly as in WinUI.

This is Phase 1: make DependencyObject a class and retire the generator mixin, while keeping DependencyObjectStore as-is. Dissolving the store into DependencyObject is a deliberate later phase.

Changed ✏️

  • DependencyObject is now a public partial class. Everything the generator used to stamp into every DO type now lives once on the base class: the __Store accessor, GetValue/SetValue/ClearValue/ReadLocalValue/GetAnimationBaseValue/Register|UnregisterPropertyChangedCallback, Dispatcher/DispatcherQueue, the binder (SetBinding/SetBindingValue/GetBindingExpression/Resume|SuspendBindings/Clear|RestoreBindings), DataContext/TemplatedParent + the DataContextChanged event, IWeakReferenceProvider, IDependencyObjectStoreProvider, IDependencyObjectInternal.OnPropertyChanged2, and ToString.
  • DataContextProperty/TemplatedParentProperty are registered a single time on DependencyObject (owner DependencyObject) instead of once per type. The store keeps consuming them unchanged — this is behaviorally equivalent: with a single shared DP, _dataContextProperty == _parentDataContextProperty, and every inheritance/precedence/UniqueId comparison in DependencyObjectStore still holds (per-type metadata still resolves via GetMetadata(forType)).

Removed 🗑️

  • DependencyObjectGenerator + its Uno0003 diagnostic + golden test. With DO as a class no type needs the injected mixin, and [Bindable] is inherited from the base (the bindable-metadata/linker scans already walk the base chain via GetAllAttributes).

Re-rooting & consumer fixes

  • IFrameworkElement no longer extends DependencyObject (a C# interface can't inherit a class). The ~handful of call sites that treated an IFrameworkElement as a DependencyObject now cast.
  • Shared partials that declared : DependencyObject while a platform partial declared the real base (TextBlock), or that listed it after an interface (RowDefinition, ColumnDefinition, NativeListViewBase), are reconciled so the base class comes first / only once.
  • where T : class, DependencyObject constraints drop the now-illegal class constraint.
  • FlyoutBase/SetterBase OnDataContextChangedPartial and RowDefinition/ColumnDefinition/Brush OnPropertyChanged2 become overrides of the base virtuals.
  • Generator DO-detection moved from interface membership (AllInterfaces/GetAllInterfaces/ImplementedInterfaces, which no longer find a base class) to base-type walks: the XAML generator, the [GeneratedDependencyProperty] generator, the bindable-availability + linker-hint generators (incl. the Cecil-based LinkerHintGeneratorTask), and the DP-mixin generator. The WinAppSDK sync generator no longer emits DependencyObject as an explicit base (it is the universal root, always provided by the hand-written partial).

Validation

  • Builds clean (0 errors / 0 warnings) on Skia (Uno.UI.Skia, SamplesApp.Skia.Generic Release, Uno.UI.RuntimeTests.Skia) and the unit-test flavor.
  • Unit tests: 4023/4035 pass. The 12 When_Gregorian_FixedDate failures are pre-existing timezone-sensitive Windows.Globalization tests (in Uno.UWP, untouched by this PR).
  • Source-generator tests: 475/475 pass — XAML codegen goldens are unchanged (base-type detection produces byte-identical output to the old interface check).
  • Runtime tests (Skia Desktop): Given_ContentControl/Given_DependencyObjectCollection/Given_DependencyObjectExtensions/Given_ToolTip/Given_Style canaries all green. The 7 Given_Flyout.Check_Placement_All_* "beyond-edge" failures reproduce identically on the base commit, so they are pre-existing window-geometry-dependent failures in the local headless host, unrelated to this change.

PR Checklist ✅

  • 🧪 Behavior-preserving refactor — covered by the existing DependencyProperty / binder / DataContext unit + runtime tests (no new behavior introduced).
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features)
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

Breaking change

DependencyObject changes from an interface to a class (source & binary breaking). Realistic impact for a typical app is narrow — using DependencyObject as a base, parameter, or return type behaves identically. Code that breaks:

  • Types that hand-implemented the DependencyObject interface on a class with another base, or relied on interface-style multiple inheritance → must now inherit the DependencyObject class.
  • Interfaces that extended DependencyObject → can no longer (an interface can't inherit a class); re-shape them or cast.
  • Reflection/source-gen that keyed off the interface shape (Type.GetInterfaces() / Roslyn AllInterfaces) → switch to base-type checks (IsAssignableFrom / base-type walks).
  • where T : class, DependencyObject constraints → drop class.

This targets the feature/breakingchanges 7.0 base, where breaking changes are expected.

🤖 Generated with Claude Code

@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 labels Jun 24, 2026
@github-actions

github-actions Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 8m 7s —— View job


Review: feat!: Make DependencyObject a class instead of an interface

  • Gather context and understand the PR
  • Review DependencyObject.cs — class definition and member moves
  • Review source generators — interface→base-type detection changes
  • Review IFrameworkElement.cs and cast sites
  • Review DependencyObjectGenerator deletion
  • Review RowDefinition/ColumnDefinition/Brush/FlyoutBase/SetterBase override changes
  • Review unit test changes
  • Review remaining changed files
  • Post inline comments
  • Post summary

Summary

Overall verdict: The refactor is sound and well-executed. The structural change is correct — DependencyObject becomes a proper base class, the mixin generator is deleted, all partial-class base-list orderings are fixed, and all generator DO-detection paths are updated to walk the base-type chain. The validation evidence (0-error/0-warning build, 4023/4035 unit tests passing, all source-generator goldens unchanged) is appropriate for a behaviour-preserving refactor of this scope.

5 findings — 0 blocking, 3 medium, 2 low:

# Severity Location Issue
1 Medium DependencyObject.cs:29 _binderTrace field is declared and initialized but never read anywhere in the codebase — dead allocation. Remove it (and the Uno.Diagnostics.Eventing using if it becomes unused).
2 Medium DependencyObject.cs:75 DataContextChanged event uses TypedEventHandler<FrameworkElement, …> as sender but lives on DependencyObject. OnDataContextChanged invokes this as FrameworkElement, which is null for non-FE DOs (e.g. SetterBase, FlyoutBase, brushes). Pre-existing behaviour from the mixin, but now more visible. Worth a follow-up to either move the event to FrameworkElement (matching WinUI 3) or widen the sender type.
3 Medium Generated/…/DependencyObjectCollection.cs:9 Hand-editing a Generated/ folder — violates AGENTS.md policy. The change is correct (the updated sync generator will produce the same output), but the file should be regenerated rather than hand-patched to keep the invariant that generated files are generator-owned.
4 Low BindableTypeProvidersGenerationTask.cs:504 / DependencyObjectAvailabilityGenerator.cs:143 IsDependencyObject helpers end with a GetAllInterfaces().Any(…) fallback that checks for DependencyObject as an interface. This branch can never be true post-PR and is dead code.
5 Low DependencyPropertyMixinGenerator.cs:275 Comment says "reference/Skia API" but the condition !UNO_REFERENCE_API correctly generates on Skia. The comment conflates Skia with reference API. Suggestion left inline.

No issues found with: base-type detection in the XAML generator (IsType reuse is correct), LinkerHintGeneratorTask DO walk (early-exit + recursion is correct), where T : class, DependencyObject constraint removals, partial-class base-list reordering (DependencyObject first), ColumnDefinition/RowDefinition/Brush moving from internal void to internal override void, FlyoutBase/SetterBase switching from partial void to override (call ordering is correct — internal sync before base event fire), unit/runtime test where T : class, DependencyObject → where T : DependencyObject cleanup, DependencyObjectStore._parentDataContextProperty fix to reference DependencyObject.DataContextProperty, and Setter<T> double-cast (T)(object) idiom (necessary since T is unconstrained).

@github-actions

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on f9be820

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

Comment thread src/Uno.UI/UI/Xaml/DependencyObject.cs Resolved
Comment thread src/Uno.UI/UI/Xaml/DependencyObject.cs Resolved
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 219597 did not find any UI Test snapshots differences.

Comment thread src/Uno.UI/UI/Xaml/DependencyObject.cs Resolved

@ajpinedam ajpinedam 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.

Agree with Xiaoy comments

Copilot AI review requested due to automatic review settings July 2, 2026 06:40
@github-actions

github-actions Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 7m 11s —— View job


Review: feat!: Make DependencyObject a class instead of an interface

  • Gather context: read the diff since the base branch
  • Review DependencyObject.cs — class definition, dead fields, sender-type mismatch
  • Review source generator DO-detection (dead interface fallbacks)
  • Review DependencyPropertyMixinGenerator.cs — inaccurate comment
  • Review Generated/ hand-edit in DependencyObjectCollection.cs
  • Review remaining changed files for new issues
  • Post inline comments for each finding
  • Post summary

Summary

Overall verdict: Sound refactor. The previous round of review findings were well-addressed: _binderTrace is removed, Grid.Properties.cs correctly uses FrameworkElement parent for direct InvalidateMeasure() dispatch, TextBlock.cs now declares its FrameworkElement base on the shared partial, all interface-based DO-detection fallbacks are gone, and DependencyObjectAvailabilityGenerator/BindableTypeProvidersGenerationTask use clean base-type walks. 2 findings remain — 1 medium, 1 low.

# Severity Location Issue
1 Medium DependencyPropertyMixinGenerator.cs:275–278 Comment still inaccurate after the latest fix: says "UNO_REFERENCE_API is defined for Skia, WebAssembly and Reference" — but UNO_REFERENCE_API ≡ __NETSTD_REFERENCE__ (reference stub only, not Skia/WASM). The behavioral change ("true" → "!UNO_REFERENCE_API") is correct; only the explanatory prose needs fixing. Suggestion posted inline.
2 Low Canvas.cs:23–41 (OnLeftChanged, OnTopChanged) Uses IFrameworkElement parent + explicit (DependencyObject)parent cross-cast to reach InvalidateArrange() via the extension method, while the equivalent Grid.Properties.cs hunk (changed in this same PR) uses FrameworkElement parent for a direct dispatch. The cast is safe but inconsistent; suggestion to use FrameworkElement parent posted inline.

No new issues found in: DependencyObject.cs member layout (DispatcherQueue init matches old mixin), TemplatedParentProperty registration on DO, LinkerHintGeneratorTask base-type recursion, XamlFileGenerator IsType reuse, ColumnDefinition/RowDefinition/Brush internal override void OnPropertyChanged2, RowDefinition/NativeListViewBase base-class ordering, Control.FindNameInScope cast to (DependencyObject)root, ItemsControlExtensions/FrameworkElementAutomationPeer/EntranceThemeTransition IFrameworkElement→DependencyObject casts (safe; pattern matches always work on types that are both), Setter<T> double-cast (T)(object), and where T : DependencyObject constraint cleanups across tests.

Carry-forward note (not a new finding): The Generated/…/DependencyObjectCollection.cs hand-edit is still present. The sync-generator fix (Generator.cs adds the type to _baseTypeExcludes) means the next automated /apply-sync-gen run will produce byte-identical output, but the file is still technically maintainer-owned rather than generator-owned until that run is committed. The PR description and CI comments already cover this; no new inline comment needed.

@MartinZikmund

Copy link
Copy Markdown
Member Author

🤖 Addressed PR comments up to this point

Rebased onto the latest feature/breakingchanges (which now includes BC58 — DataContext restricted to FrameworkElement) and addressed every open review thread in 5848a5e629:

  • @Xiaoy312 — DependencyObjectCollection still inherits DependencyObject (transitively, as a class); extracted the DO-detection helper in DependencyPropertyGenerator; removed the dead LinkerHintGeneratorTask interface fallback; Grid now invalidates measure via the FrameworkElement instance method; TextBlock declares FrameworkElement on the shared partial; DependencyObject long signatures shortened via usings.
  • @ajpinedam — thanks for the review; the Xiaoy comments you agreed with are all addressed above.
  • Automated review — removed the unused _binderTrace field; DataContextChanged is FrameworkElement-only now (sender is never null); reverted the blanket sync-gen base skip and scoped it to DependencyObjectCollection; removed the dead interface fallbacks; clarified the ItemsWrapGridLayout mixin comment (UNO_REFERENCE_API covers Skia).

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.

Pull request overview

This PR performs a breaking refactor to align Uno with WinUI by changing Microsoft.UI.Xaml.DependencyObject from an interface (with per-type generated “mixin” plumbing) into a real base class, and updates generators/call-sites accordingly now that the historical native-target constraint is gone.

Changes:

  • Convert DependencyObject to a base class that owns the DependencyObjectStore/binder plumbing, instead of relying on DependencyObjectGenerator-injected members.
  • Update framework code to accommodate IFrameworkElement no longer inheriting DependencyObject, including updated casts, base-type ordering, overrides, and generic constraints.
  • Update source generators and the WinAppSDK sync generator to detect DependencyObject via base-type walks; remove DependencyObjectGenerator and its diagnostics/tests.

Reviewed changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Uno.WinAppSDKSyncGenerator/Generator.cs Prevents sync generator from emitting a conflicting DependencyObject base for DependencyObjectCollection.
src/Uno.UI/UI/Xaml/Setter.Generic.cs Adjusts generic casts after DependencyObject becomes a class.
src/Uno.UI/UI/Xaml/Media/Brush.cs Switches OnPropertyChanged2 to override the new base virtual.
src/Uno.UI/UI/Xaml/Media/Animation/EntranceThemeTransition.cs Updates storyboard target assignment via explicit DependencyObject cast.
src/Uno.UI/UI/Xaml/IFrameworkElement.cs Removes DependencyObject from interface inheritance; updates template-child helper cast.
src/Uno.UI/UI/Xaml/DependencyObject.cs Introduces DependencyObject base class implementation (store, binder hooks, templated parent DP, binding APIs).
src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.cs Reconciles inheritance now that DependencyObject is a base class (derives from FrameworkElement).
src/Uno.UI/UI/Xaml/Controls/MediaPlayerElement/MediaTransportControls.cs Updates generic constraints (where T : DependencyObject).
src/Uno.UI/UI/Xaml/Controls/ListViewBase/NativeListViewBase.cs Makes NativeListViewBase inherit DependencyObject (base class first).
src/Uno.UI/UI/Xaml/Controls/ItemsControl/ItemsControlExtensions.cs Adds cast where IItemsControl is passed where a DependencyObject is required.
src/Uno.UI/UI/Xaml/Controls/Grid/RowDefinition.cs Re-roots inheritance and overrides OnPropertyChanged2.
src/Uno.UI/UI/Xaml/Controls/Grid/Grid.Properties.cs Updates parent pattern/casts after IFrameworkElement change.
src/Uno.UI/UI/Xaml/Controls/Grid/ColumnDefinition.cs Re-roots inheritance and overrides OnPropertyChanged2.
src/Uno.UI/UI/Xaml/Controls/Control/Control.cs Updates template helpers and NameScope access to use DependencyObject casts.
src/Uno.UI/UI/Xaml/Controls/Canvas/Canvas.cs Updates invalidation calls to work with new type relationships (via DependencyObject extension).
src/Uno.UI/UI/Xaml/Automation/Peers/FrameworkElementAutomationPeer.cs Adds explicit DependencyObject cast for automation attached-property APIs.
src/Uno.UI/UI/Xaml/AttachedDependencyObject.cs Removes now-unnecessary binder init call from constructor.
src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml/DependencyObjectCollection.cs Removes explicit DependencyObject base emission from generated stub.
src/Uno.UI/Controls/Renderer.cs Simplifies generic constraint now that DependencyObject is a class.
src/Uno.UI.UnitTests/DependencyProperty/Given_DependencyProperty.Type.cs Updates unit tests to detect DO via IsAssignableFrom instead of interfaces.
src/Uno.UI.UnitTests/DependencyProperty/Given_DependencyProperty.Owner.cs Same DO detection update for owner checks.
src/Uno.UI.RuntimeTests/MUX/Utilities/VisualTreeUtils.cs Simplifies generic constraints to where T : DependencyObject.
src/Uno.UI.RuntimeTests/MUX/Utilities/TestHelpers.cs Simplifies generic constraints to where T : DependencyObject.
src/SourceGenerators/Uno.UI.Tasks/LinkerHintsGenerator/LinkerHintGeneratorTask.cs Updates Cecil-based DO detection to base-type recursion.
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.Reflection.cs Updates DO detection logic used by XAML generation.
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs Replaces interface checks with base-type checks (IsType).
src/SourceGenerators/Uno.UI.SourceGenerators/DependencyObject/DependencyObjectGenerator.Diagnostics.cs Removes obsolete diagnostic definition (generator retired).
src/SourceGenerators/Uno.UI.SourceGenerators/DependencyObject/DependencyObjectGenerator.cs Removes generator that previously injected DO mixin members.
src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/DependencyObjectAvailabilityGenerator.cs Updates DO detection to walk base-type chain.
src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/BindableTypeProvidersGenerationTask.cs Updates DO detection to walk base-type chain.
src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs Removes tests tied to removed DependencyObjectGenerator.
src/SourceGenerators/Uno.UI.SourceGenerators.Internal/Mixins/DependencyPropertyMixinGenerator.cs Adjusts mixin generation condition for a type that is only DO on some builds.
src/SourceGenerators/Uno.UI.SourceGenerators.Internal/DependencyObject/DependencyPropertyGenerator.cs Updates DO detection to base-type chain for generated DP plumbing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Uno.UI/UI/Xaml/DependencyObject.cs Resolved
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 220460 did not find any UI Test snapshots differences.

@github-actions

github-actions Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 5s —— View job


Review: feat!: Make DependencyObject a class instead of an interface

  • Gather context and read the diff since base branch
  • Verify UNO_REFERENCE_API scope from Uno.CrossTargetting.targets — comment is correct, prior automated review was wrong
  • Review Canvas.cs — inconsistency with Grid.Properties.cs (still present)
  • Check unused using directives in DependencyObject.cs
  • Post inline comments
  • Post summary

Summary

Overall verdict: This is a well-executed, architecturally clean refactor. All prior blocking review threads have been addressed. 2 low-severity findings remain.

# Severity Location Issue
1 Low DependencyObject.cs:2–8 Four unused using directives (System.Collections, System.Collections.Generic, System.Linq, Uno.Disposables) — carried from the old generator mixin, not referenced in this partial file. Will surface as IDE0005 warnings in strict CI builds.
2 Low Canvas.cs:23–26, 38–41 OnLeftChanged and OnTopChanged use Parent: IFrameworkElement parent + ((DependencyObject)parent).InvalidateArrange(), while Grid.Properties.cs was correctly updated in this PR to use Parent: FrameworkElement parent + parent.InvalidateArrange() directly. The cross-cast is safe in practice but inconsistent and unnecessarily indirect.

Correction for the carry-forward thread on DependencyPropertyMixinGenerator.cs: The previous automated review (July 2) continued to claim the comment was inaccurate. That finding was itself wrong. Uno.CrossTargetting.targets explicitly documents UNO_REFERENCE_API as "true for Skia, Wasm, and Reference" (while __NETSTD_REFERENCE__ is reference-only). The comment on line 275 stating "UNO_REFERENCE_API is defined for Skia, WebAssembly and Reference" is therefore correct, and @MartinZikmund's response was accurate. No change needed there.

No new issues found in: DependencyPropertyGenerator.cs interface fallback (intentional — explained clearly in the commit message; needed while the released package still ships DependencyObject-as-interface), BindableTypeProvidersGenerationTask and DependencyObjectAvailabilityGenerator DO-detection (clean base-type walk, no dead fallbacks), LinkerHintGeneratorTask (interface fallback correctly removed), DependencyObject.cs class layout, TemplatedParentProperty registration, IFrameworkElement cast sites, RowDefinition/ColumnDefinition/Brush OnPropertyChanged2 overrides, FlyoutBase/SetterBase override ordering, generic constraint cleanups, and DependencyObjectCollection.cs sync-generator fix.

Comment thread src/Uno.UI/UI/Xaml/DependencyObject.cs Resolved
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 50s —— View job


Review: feat!: Make DependencyObject a class instead of an interface

  • Gather context and read the diff since base branch
  • Verify carry-forward findings are resolved (DependencyObject.cs unused usings, Canvas.cs pattern inconsistency)
  • Review latest commit (74d1d820) for new issues
  • Post inline comments
  • Post summary

Summary

Overall verdict: Both remaining low-severity carry-forward findings are fully resolved in 74d1d82024. 0 findings remaining.

Finding Status
DependencyObject.cs — four unused using directives (System.Collections, System.Collections.Generic, System.Linq, Uno.Disposables) ✅ Removed
Canvas.cs OnLeftChanged/OnTopChanged — IFrameworkElement parent + ((DependencyObject)parent) cross-cast ✅ Now uses FrameworkElement parent + direct parent.InvalidateArrange()

Additional cleanup noted: OnZIndexChanged was also tightened from (dependencyObject as IFrameworkElement)?.InvalidateArrange() to an explicit if (dependencyObject is IFrameworkElement) { dependencyObject.InvalidateArrange(); } with braces — consistent with the code-style rule (always use braces) and semantically equivalent in practice (all IFrameworkElement implementations are UIElement subclasses, so the extension method resolves to (UIElement)dependencyObject).

No new issues found. The refactor is clean, all prior review threads are addressed, and the PR is ready from an automated-review standpoint.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 221024 did not find any UI Test snapshots differences.

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 54s —— View job


Review: feat!: Make DependencyObject a class instead of an interface

  • Gather context and read the diff since base branch
  • Review new changes since last review round (74d1d820, 60d41fb0)
  • Post inline comments for any findings
  • Post summary

Summary

Overall verdict: Both remaining low-severity carry-forward findings are fully resolved. 0 findings remaining. The refactor is complete and ready from an automated-review standpoint.

Finding Status
DependencyObject.cs — four unused using directives (System.Collections, System.Collections.Generic, System.Linq, Uno.Disposables) ✅ Removed in 74d1d820
Canvas.cs OnLeftChanged/OnTopChanged — IFrameworkElement parent + ((DependencyObject)parent) cross-cast ✅ Fixed in 60d41fb0 — now uses FrameworkElement parent + direct parent.InvalidateArrange()

No new issues found in: DependencyObject.cs class layout and usings; Canvas.cs OnZIndexChanged braces cleanup; DependencyPropertyGenerator.cs IsDependencyObject helper with retained interface fallback (correctly documented — needed while released package still ships DO as interface); BindableTypeProvidersGenerationTask / DependencyObjectAvailabilityGenerator clean base-type walks; LinkerHintGeneratorTask self-check before recursion; UIViewExtensions.cs (object?)view as DependencyObject cross-hierarchy cast; PackageDiffIgnore.xml regex entries for all 22 relocated members; Grid.Properties.cs FrameworkElement parent pattern; ColumnDefinition/RowDefinition/Brush internal override void OnPropertyChanged2; Setter<T> (T)(object) double-cast (required for unconstrained generic); where T : DependencyObject constraint cleanups; IFrameworkElement DependencyObject removal and cast fixes.

Comment thread src/Uno.UI/UI/Xaml/Setter.Generic.cs Resolved
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 221056 found UI Test snapshots differences: skia-linux-screenshots: 0, skia-windows-screenshots: 76

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

  • skia-windows-screenshots: 76 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • ImagesInlineInFlipView.png-dark
    • ImagesInlineInFlipView.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Image_AnimatedWebP.png
    • Gamepad_Enumeration.png-dark
    • ImageIconPage.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ImageBrushInList.png-dark

MartinZikmund and others added 9 commits July 8, 2026 09:29
Prepares the generators for DependencyObject becoming a class instead of
an interface (BC26): interface-membership checks (AllInterfaces /
GetAllInterfaces) no longer find a base class, so route DependencyObject
detection through base-type walks. Also stop the WinAppSDK sync generator
from emitting DependencyObject as an explicit base (it is the universal
root, always provided by the hand-written partial), and gate the
ItemsWrapGridLayout mixin to the non-reference build where it is a DO.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01V1DDwHqUPDocBBHeu1YX3Z
BC26 (uno-private #2055). The interface only ever existed because native
mobile UIElement had to inherit a native view; with the native targets
dropped, DependencyObject becomes a normal base class as in WinUI.

The per-type mixin the DependencyObjectGenerator used to inject (store,
GetValue/SetValue, binder, DataContext/TemplatedParent, IWeakReference
Provider, IDependencyObjectInternal, ToString, [Bindable]) now lives once
on the DependencyObject base class. DataContextProperty and Templated
ParentProperty are registered a single time on the base (ownerType =
DependencyObject) rather than per type; the store keeps using them
unchanged (the DependencyObjectStore itself is untouched - that is a
later phase). The generator and its diagnostics/tests are removed.

Re-rooting and consumer fixes:
- IFrameworkElement no longer extends DependencyObject (an interface can
  no longer inherit the class); call sites that used IFrameworkElement as
  a DependencyObject now cast.
- Shared partials that declared ": DependencyObject" while a platform
  partial declared the real base (TextBlock) or that listed it after an
  interface (RowDefinition, ColumnDefinition, NativeListViewBase) are
  reconciled so the base class comes first / only once.
- "where T : class, DependencyObject" constraints drop the now-illegal
  class constraint.
- FlyoutBase/SetterBase OnDataContextChangedPartial and RowDefinition/
  ColumnDefinition/Brush OnPropertyChanged2 become overrides of the base
  virtuals.

Builds clean on Skia (net10.0).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01V1DDwHqUPDocBBHeu1YX3Z
The blanket skip added while flipping DependencyObject to a class dropped the
DependencyObject base from every sync-generated stub, but only the
DependencyObjectCollection stub was updated to match, so regeneration diverged
from the other committed stubs (AutomationPeer, ColumnDefinition, …) and the
WinAppSDK Sync Generator Check failed.

DependencyObjectCollection derives from DependencyObjectCollection<DependencyObject>
in the hand-written partial (which carries the DependencyObject base and the IList
implementation), so only its metadata base must be suppressed. Move it into the
existing _skipBaseTypes mismatched-hierarchy list and let every other type keep
emitting its DependencyObject base.

Addresses review threads on DependencyObjectCollection base (it still derives from
DependencyObject, transitively, as a class).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_016g1Lvg4ET5pPXX5fdWT7TB
Now that DependencyObject is a class it can never appear in a type's interface
list, so the interface fallbacks in the DO-detection helpers are dead. Drop them
(BindableTypeProvidersGenerationTask, DependencyObjectAvailabilityGenerator,
LinkerHintGeneratorTask) and extract the base-chain walk in DependencyPropertyGenerator
into a shared IsDependencyObject helper mirroring the other generators.

Also clarify the ItemsWrapGridLayout mixin comment: UNO_REFERENCE_API is defined for
Skia, WebAssembly and Reference (Uno.CrossTargetting.targets), so the mixin is emitted
only for the native (!UNO_REFERENCE_API) build.

Addresses review comments on the generator DO-detection helpers.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_016g1Lvg4ET5pPXX5fdWT7TB
- DependencyObject: remove the unused _binderTrace field (and its
  Uno.Diagnostics.Eventing using) and shorten the fully-qualified member
  signatures by importing the relevant namespaces.
- Grid: invalidate the parent's measure through the FrameworkElement instance
  method instead of the DependencyObject extension, matching the distinct
  IFrameworkElement/DependencyObject implementations.
- TextBlock: declare the FrameworkElement base on the shared partial for parity
  with the platform partials.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_016g1Lvg4ET5pPXX5fdWT7TB
The DependencyPropertyGenerator tests compile `class C : DependencyObject`
against the released Uno package (WithUnoPackage), where DependencyObject is
still an interface, so base-chain-only detection missed those types and the
golden tests (TestInDependencyObject, TestGetDefaultValuePresentWithDefaultValueArgument)
regressed. Restore the implemented-interface match inside the extracted helper;
it becomes removable once a stable release ships DependencyObject-as-class.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_016g1Lvg4ET5pPXX5fdWT7TB
With DependencyObject now a class (not an interface), `view as DependencyObject`
on a UIKit.UIView no longer compiles (CS0039 — no reference conversion exists),
which broke the AppleUIKit Skia head build. Route the cast through object so it
compiles and preserves the runtime check (non-null only if the view actually is
a DependencyObject).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_016g1Lvg4ET5pPXX5fdWT7TB
DependencyObject is now a base class (BC26). The store, binder and
TemplatedParent members that the DependencyObjectGenerator used to emit on
every type are now inherited from the base, so the API diff reports them as
"removed" on ~100 previously-declaring types. They remain available (inherited).
Add regex ignore entries covering the 22 relocated method signatures (plus the
five property-backed members) across all types, alongside the BC58 DataContext
entries in the same baseline ignore set.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_016g1Lvg4ET5pPXX5fdWT7TB
- Canvas Left/Top handlers match on FrameworkElement and call
  InvalidateArrange() directly, matching Grid.Properties.cs and
  dropping the (DependencyObject) cross-cast.
- Remove four unused usings from DependencyObject.cs.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01PYb2VuYxKqicfJRcXkdDVv
@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 7m 9s —— View job


Review: feat!: Make DependencyObject a class instead of an interface

  • Gather context and read PR diff
  • Review Setter.Generic.cs — file no longer in PR diff (resolved in base branch)
  • Review NativeListViewBase.cs — base-class ordering fix; file is #if !UNO_REFERENCE_API only (not compiled on Skia/WASM/Reference)
  • Review Generator.cs — DependencyObjectCollection hierarchy is sound (base comes from hand-written partial chain, not generated stub)
  • Check UI snapshot differences (76 changed on skia-windows in build 221056)
  • Review full diff for new line-level issues
  • Post inline comments
  • Post summary

Summary

Overall verdict: No new findings. All previous review threads are resolved and the PR is clean.

UI snapshot differences — needs investigation: Build 221056 (skia-windows) reported 76 changed screenshots versus 0 in the 4 preceding builds (220460, 220486, 220848, 221024). The affected samples span unrelated controls — Buttons, CalendarView_Theming, Gamepad_CurrentReading, ImageBrushInList, ElementLevelTheme, etc. — with no apparent connection to the Canvas.Left/Top handler change in f6f222dd that landed between builds 221024 and 221056. This breadth strongly suggests CI environment noise (Windows rendering stack, font or DPI difference) rather than a code regression. However, the team should confirm this before merging by either re-running the job or checking whether the baseline images need updating.

Confirmed resolved:

  • DependencyObject.cs — unused using directives (System.Collections, System.Collections.Generic, System.Linq, Uno.Disposables) removed ✅
  • Canvas.cs OnLeftChanged/OnTopChanged — now use Parent: FrameworkElement parent + direct parent.InvalidateArrange(), consistent with Grid.Properties.cs ✅
  • DependencyObjectCollection — inherits DependencyObject through the hand-written chain (DependencyObjectCollection → DependencyObjectCollection<DependencyObject> → DependencyObjectCollectionBase → DependencyObject); generated stub correctly omits the redundant explicit base ✅
  • Setter.Generic.cs — no longer in the PR diff; the concern is moot ✅
  • Explicit (DependencyObject) casts in EntranceThemeTransition.cs, FrameworkElementAutomationPeer.cs, Control.cs, ItemsControlExtensions.cs — all cross internal-only interfaces where callers always provide UIElement/FrameworkElement instances; safe ✅
  • DependencyPropertyGenerator.cs interface fallback — correctly retained with a clear comment; required while generator tests compile against a released package where DO is still an interface ✅
  • NativeListViewBase.cs — #if !IS_UNIT_TESTS && !UNO_REFERENCE_API excludes this from Skia/WASM/Reference builds; base-class reorder is the correct syntactic fix ✅
  • AttachedDependencyObject.cs — InitializeBinder() removal is correct; the method body is { } (no-op) and the binder is now lazily initialized from __Store ✅

No new issues found in: DependencyObject.cs class layout; Canvas.cs OnZIndexChanged (extension method DependencyObjectExtensions.InvalidateArrange correctly resolves to UIElement.InvalidateArrange()); Generator.cs _skipBaseTypes entry for DependencyObjectCollection; IFrameworkElement.cs GetTemplateChild returning FindName(name) as DependencyObject; Brush.cs/ColumnDefinition.cs/RowDefinition.cs internal override void OnPropertyChanged2; Control.cs where T : DependencyObject constraint; VisualTreeUtils.cs/TestHelpers.cs generic constraint cleanups.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 221237 found UI Test snapshots differences: skia-linux-screenshots: 0, skia-windows-screenshots: 77

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

  • skia-windows-screenshots: 77 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Focus_FocusVisual_Properties.png-dark
    • Image_UseTargetSize.png-dark
    • Buttons.png-dark
    • Buttons.png
    • ColorPickerSample.png
    • DropDownButtonPage.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • Gamepad_Enumeration.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

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

@MartinZikmund
MartinZikmund enabled auto-merge July 8, 2026 12:33
@MartinZikmund
MartinZikmund merged commit 3cd81dd into feature/breakingchanges Jul 8, 2026
66 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/do-class branch July 8, 2026 12:51
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 platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants