Skip to content

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

Merged
agneszitte merged 4 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-25141
Nov 1, 2026
Merged

agneszitte merged 4 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-25141

Conversation

@mergify

@mergify mergify Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

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


This is an automatic backport of pull request #25141 done by [Mergify](https://mergify.com).

MartinZikmund and others added 3 commits November 1, 2026 21:49
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
(cherry picked from commit bf5e27f)

# Conflicts:
#	build/PackageDiffIgnore.xml
…ignature

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01E8bkzyS24p8CYDWLUPsaPC
(cherry picked from commit ee008e6)

# Conflicts:
#	src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Automation/Given_ListViewBaseAutomationPeer.cs
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
(cherry picked from commit 4bb1482)
@mergify mergify Bot added the conflicts Automated merge hit conflicts label Nov 1, 2026
@mergify

mergify Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

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

@github-actions github-actions Bot added the area/build Categorizes an issue or PR as relevant to build infrastructure label Nov 1, 2026
Mergify's cherry-pick left conflict markers and master's whole 6.7 ignore
set in the file. Restore this branch's version and add a 6.7 set (the
latest stable on nuget.org, which the package diff compares against) with
the one removed member: List<AutomationPeer> GetChildrenCore().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@agneszitte
agneszitte merged commit 97bc3ca into release/stable/6.7 Nov 1, 2026
20 of 33 checks passed
@agneszitte
agneszitte deleted the mergify/bp/release/stable/6.7/pr-25141 branch November 1, 2026 22:15
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

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 conflicts Automated merge hit conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants