Skip to content

fix(automation): Align ListViewBaseAutomationPeer.GetChildrenCore return type with WinUI - #25141

Merged
MartinZikmund merged 3 commits into
masterfrom
dev/mazi/listviewbase-peer-getchildrencore
Oct 9, 2026
Merged

MartinZikmund merged 3 commits into
masterfrom
dev/mazi/listviewbase-peer-getchildrencore

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #24552

PR Type:

🐞 Bugfix

What changed? 🚀

ListViewBaseAutomationPeer.GetChildrenCore() was declared as protected override List<AutomationPeer> GetChildrenCore(), a C# 9 covariant return. WinUI (and Uno's own AutomationPeer, FrameworkElementAutomationPeer and ItemsControlAutomationPeer) use IList<AutomationPeer>. Because of the covariant return, every override below ListViewBaseAutomationPeer had to return List<AutomationPeer>:

Changes

  1. Fix: ListViewBaseAutomationPeer.GetChildrenCore() now returns IList<AutomationPeer>, matching WinUI. No internal caller relied on List<T>. Added a PackageDiffIgnore.xml entry (6.7 set) for the removed List<T>-returning signature, which shipped in 6.6 and 6.7.
  2. Test: Given_ListViewBaseAutomationPeer.When_GetChildrenCore_Overridden_With_WinUI_Signature overrides GetChildrenCore with the WinUI signature on a ListViewAutomationPeer subclass and checks that the override runs and returns the item peers. Without the fix it does not compile (CS0508).
  3. Sync generator: it now reports this kind of divergence (details below).

Why the WinAppSDK sync generator didn't flag it

The generator walks only the members declared on each WinUI type: BuildMethods iterates type.GetMembers() (src/Uno.WinAppSDKSyncGenerator/Generator.cs, BuildMethods). For each of those it looks for a hand-written Uno match with FindMatchingMethod → SymbolMatchingHelpers.AreMethodsMatching. That check does compare return types (AreMatching(uapMethod.ReturnType, unoMethod.ReturnType)). If they differ, it emits a duplicate stub, and the build fails with CS0111. So a mismatch on a member WinUI declares on that same type cannot slip through.

The WinUI projection declares GetChildrenCore only on AutomationPeer, where the overridable interface lives. Derived peers such as ListViewBaseAutomationPeer don't re-declare it, so the generator never visits Uno's ListViewBaseAutomationPeer.GetChildrenCore override and nothing compares it to WinUI. You can see this in the generated output: Generated/3.0.0.0/Microsoft.UI.Xaml.Automation.Peers/AutomationPeer.cs contains // Skipping already declared method ...AutomationPeer.GetChildrenCore(), and ListViewBaseAutomationPeer.cs has no GetChildrenCore line at all.

For an override, the only way to diverge from WinUI's signature is a covariant return or property type. WinRT has no covariant returns. So the new BuildOverrideTypeMismatchErrors check looks at the hand-written public/protected overrides on each WinUI type (on every platform variant). If an override's return or property type differs from the member it overrides, the check writes an #error into the generated file. The existing enum mismatch check reports problems the same way.

Other mismatches found

To find other existing divergences, I scanned the compiled API surface with MetadataLoadContext. The scan looked for public/protected members whose return or property type differs from a same-signature base member, whether through a covariant override or through hiding with new. It covered:

  • Uno.WinUI 7.0.0-dev.1656 (Uno.UI, Uno.UI.Composition, …) on net10.0
  • Uno.Foundation, Uno.WinRT and Uno.Foundation.Logging on net10.0, android, ios and tvos, plus the wasm runtime variant
  • Uno.WinUI.Runtime

Results:

  • WinUI API surface: ListViewBaseAutomationPeer.GetChildrenCore was the only mismatch, and this PR fixes it.
  • Outside the WinUI surface: the only other hits are the compiler-generated record <Clone>$ methods in Uno.UI.Composition.Drawing, which is Uno's own namespace. The generator doesn't check those types.

So with this PR the new check produces no #error, and there should be no generated-file drift.

Validation

  • Runtime (Skia desktop, net10.0-desktop, Release): Given_ListViewBaseAutomationPeer, 1 test run, 1 passed.
  • Fail-before: with the fix reverted, Uno.UI.RuntimeTests.Skia fails to compile with error CS0508: 'Given_ListViewBaseAutomationPeer.CustomListViewAutomationPeer.GetChildrenCore()': return type must be 'List<AutomationPeer>'.
  • Generator: the generator builds. I didn't run the full sync locally because the tvOS workload and .NET 11 SDK are missing on my machine, so the WinAppSDK Sync Generator Check workflow covers that run. I tested BuildOverrideTypeMismatchErrors with an out-of-tree harness that calls it on a Roslyn compilation:
    • A covariant method override and a covariant property override each produce one #error.
    • Overrides with matching types produce nothing.

PR Checklist ✅

Breaking change (binary, intentional): ListViewBaseAutomationPeer.GetChildrenCore() now returns IList<AutomationPeer> instead of List<AutomationPeer>, which aligns it with WinUI. Code that overrode it with List<AutomationPeer> (an Uno-only workaround) needs to switch to IList<AutomationPeer>, the same signature that already works on WinUI.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E8bkzyS24p8CYDWLUPsaPC

MartinZikmund and others added 3 commits October 9, 2026 11:51
ListViewBaseAutomationPeer.GetChildrenCore used a covariant List<AutomationPeer>
return, so overrides with the WinUI IList<AutomationPeer> signature failed with
CS0508 (or TypeLoadException for prebuilt libraries such as the CommunityToolkit
TokenizingTextBox).

Fixes #24552

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01E8bkzyS24p8CYDWLUPsaPC
WinUI members are only matched on the type that declares them, so a covariant
override on a derived type (e.g. ListViewBaseAutomationPeer.GetChildrenCore)
was never compared. Emit an #error for hand-written public/protected overrides
whose return or property type differs from the overridden member.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01E8bkzyS24p8CYDWLUPsaPC
Copilot AI balanced review requested due to automatic review settings October 9, 2026 09:51

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 the area/build Categorizes an issue or PR as relevant to build infrastructure label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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


Review of #25141

Verdict: ship (0 blocking, 0 high, 1 low-severity note)

I read the diff by inspection only. I didn't build or run anything, so the runtime validation below is the author's claim, not something I checked.

Fix. GetChildrenCore now returns IList<AutomationPeer>, which matches AutomationPeer, FrameworkElementAutomationPeer, ItemsControlAutomationPeer and WinUI. The change is one line. The PackageDiffIgnore.xml entry covers the intended binary break, and the PR description discloses it.

Test. The runtime test overrides with the WinUI signature, so it fails to compile (CS0508) without the fix. That gives the fail-before/pass-after evidence the repo asks for.

Sync generator.

  • The is Public or Protected or ProtectedOrInternal pattern inside the && chain parses correctly.
  • SymbolEqualityComparer.Default ignores nullability annotations, so there are no false positives from ? differences.
  • Generated files are excluded, and Distinct() avoids duplicate errors across platform symbols.
  • Low: a generic method override (T Foo<T>()) could compare the override's method type parameter against the overridden member's, and SymbolEqualityComparer would treat them as different. This would produce a false #error. The PR's scan found no such member in the WinUI surface, so it is not a problem today. If it ever fires, compare after substituting type parameters, or skip methods where IsGenericMethod is true.
  • Not checked: the WinAppSDK Sync Generator Check workflow is what exercises the new code on real types. Wait for it to pass before merging, since the author couldn't run the full sync locally.

Housekeeping.

  • The PR checklist item "Contains NO breaking changes" is unchecked, which is consistent with the disclosed break.
  • The commits follow Conventional Commits.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 238473 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 1165

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

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • DisplayInformation.png-dark
    • DropDownButtonPage.png-dark
    • Examples.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImageBrushAlignmentXY.png-dark
    • ImageBrushAlignmentXY.png
  • skia-windows-screenshots: 1165 changed over 2474

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AppBarButtonWithIconTest.png-dark
    • Attributed_text_Simple.png
    • BindableDrawerLayout_ChangePane.png-dark
    • BindableDrawerLayout_ChangePane.png
    • BorderLeftwithmargins.png-dark
    • BorderLeftwithmargins.png
    • BorderVersusPanelClipping.png-dark
    • BorderVersusPanelClipping.png
    • Button_Opacity_Automated.png-dark
    • Button_Opacity_Automated.png
    • ComboBox_DropDownPlacement.png-dark
    • ComboBox_DropDownPlacement.png
    • ComboBox_ScrollViewer.png-dark
    • ComboBox_ScrollViewer.png
    • ContentControl_ComboBoxSetNull.png-dark
    • ContentControl_ComboBoxSetNull.png
    • Accessibility_ScreenReader.png-dark
    • AppWindowFeatures.png
    • Attributed_text_Simple.png-dark

@MartinZikmund
MartinZikmund disabled auto-merge October 9, 2026 11:07
@MartinZikmund
MartinZikmund merged commit 742ca53 into master Oct 9, 2026
55 of 57 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/listviewbase-peer-getchildrencore branch October 9, 2026 11:08
MartinZikmund added a commit to MartinZikmund/CommunityToolkitWindows that referenced this pull request Oct 27, 2026
Bumps tooling to the matching Uno.WinUI 7.0.0-dev.2428, which returns IList<AutomationPeer>
from ListViewBaseAutomationPeer.GetChildrenCore (unoplatform/uno#25141), so the
TokenizingTextBoxAutomationPeer signature shim is no longer needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu1DnHGnhiqjJz6RnRw
@agneszitte

Copy link
Copy Markdown
Member

@Mergifyio backport servicing/6.8 release/stable/6.7

@mergify

mergify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

backport servicing/6.8 release/stable/6.7

✅ Backports have been created

Details

Cherry-pick of bf5e27f has failed:

On branch mergify/bp/servicing/6.8/pr-25141
Your branch is up to date with 'origin/servicing/6.8'.

You are currently cherry-picking commit bf5e27f.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   src/Uno.UI/UI/Xaml/Automation/Peers/ListViewBaseAutomationPeer.cs

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   build/PackageDiffIgnore.xml

Cherry-pick of ee008e6 has failed:

On branch mergify/bp/servicing/6.8/pr-25141
Your branch is ahead of 'origin/servicing/6.8' by 1 commit.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit ee008e6.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	added by them:   src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Automation/Given_ListViewBaseAutomationPeer.cs

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Cherry-pick of bf5e27f has failed:

On branch mergify/bp/release/stable/6.7/pr-25141
Your branch is up to date with 'origin/release/stable/6.7'.

You are currently cherry-picking commit bf5e27f.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   src/Uno.UI/UI/Xaml/Automation/Peers/ListViewBaseAutomationPeer.cs

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   build/PackageDiffIgnore.xml

Cherry-pick of ee008e6 has failed:

On branch mergify/bp/release/stable/6.7/pr-25141
Your branch is ahead of 'origin/release/stable/6.7' by 1 commit.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit ee008e6.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	added by them:   src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Automation/Given_ListViewBaseAutomationPeer.cs

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

agneszitte added a commit that referenced this pull request Nov 1, 2026
…6.7/pr-25141

fix(automation): Align ListViewBaseAutomationPeer.GetChildrenCore return type with WinUI (backport #25141)
agneszitte added a commit that referenced this pull request Nov 1, 2026
…r-25141

fix(automation): Align ListViewBaseAutomationPeer.GetChildrenCore return type with WinUI (backport #25141)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Categorizes an issue or PR as relevant to build infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Skia/macOS] TokenizingTextBox crashes with TypeLoadException: incompatible GetChildrenCore return type

4 participants