Repository navigation
fix(automation): Align ListViewBaseAutomationPeer.GetChildrenCore return type with WinUI (backport #25141) - #25892
Merged
agneszitte merged 4 commits intoNov 1, 2026
Conversation
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)
Contributor
Author
|
Cherry-pick of bf5e27f has failed: Cherry-pick of ee008e6 has failed: 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 |
Merged
1 of 5 tasks
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
approved these changes
Nov 1, 2026
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: closes #24552
PR Type:
🐞 Bugfix
What changed? 🚀
ListViewBaseAutomationPeer.GetChildrenCore()was declared asprotected override List<AutomationPeer> GetChildrenCore(), a C# 9 covariant return. WinUI (and Uno's ownAutomationPeer,FrameworkElementAutomationPeerandItemsControlAutomationPeer) useIList<AutomationPeer>. Because of the covariant return, every override belowListViewBaseAutomationPeerhad to returnList<AutomationPeer>:CS0508: return type must be 'List<AutomationPeer>' to match overridden member 'ListViewBaseAutomationPeer.GetChildrenCore()'.TokenizingTextBoxAutomationPeer) threwTypeLoadExceptionat runtime, as reported in [Skia/macOS] TokenizingTextBox crashes with TypeLoadException: incompatible GetChildrenCore return type #24552.Changes
ListViewBaseAutomationPeer.GetChildrenCore()now returnsIList<AutomationPeer>, matching WinUI. No internal caller relied onList<T>. Added aPackageDiffIgnore.xmlentry (6.7 set) for the removedList<T>-returning signature, which shipped in 6.6 and 6.7.Given_ListViewBaseAutomationPeer.When_GetChildrenCore_Overridden_With_WinUI_SignatureoverridesGetChildrenCorewith the WinUI signature on aListViewAutomationPeersubclass and checks that the override runs and returns the item peers. Without the fix it does not compile (CS0508).Why the WinAppSDK sync generator didn't flag it
The generator walks only the members declared on each WinUI type:
BuildMethodsiteratestype.GetMembers()(src/Uno.WinAppSDKSyncGenerator/Generator.cs,BuildMethods). For each of those it looks for a hand-written Uno match withFindMatchingMethod→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
GetChildrenCoreonly onAutomationPeer, where the overridable interface lives. Derived peers such asListViewBaseAutomationPeerdon't re-declare it, so the generator never visits Uno'sListViewBaseAutomationPeer.GetChildrenCoreoverride 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.cscontains// Skipping already declared method ...AutomationPeer.GetChildrenCore(), andListViewBaseAutomationPeer.cshas noGetChildrenCoreline 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
BuildOverrideTypeMismatchErrorscheck looks at the hand-writtenpublic/protectedoverrides 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#errorinto 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 withnew. It covered:Uno.WinUI7.0.0-dev.1656 (Uno.UI,Uno.UI.Composition, …) on net10.0Uno.Foundation,Uno.WinRTandUno.Foundation.Loggingon net10.0, android, ios and tvos, plus the wasm runtime variantUno.WinUI.RuntimeResults:
ListViewBaseAutomationPeer.GetChildrenCorewas the only mismatch, and this PR fixes it.<Clone>$methods inUno.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
net10.0-desktop, Release):Given_ListViewBaseAutomationPeer, 1 test run, 1 passed.Uno.UI.RuntimeTests.Skiafails to compile witherror CS0508: 'Given_ListViewBaseAutomationPeer.CustomListViewAutomationPeer.GetChildrenCore()': return type must be 'List<AutomationPeer>'.synclocally because the tvOS workload and .NET 11 SDK are missing on my machine, so theWinAppSDK Sync Generator Checkworkflow covers that run. I testedBuildOverrideTypeMismatchErrorswith an out-of-tree harness that calls it on a Roslyn compilation:#error.PR Checklist ✅
Screenshots Compare Test Runresults.Breaking change (binary, intentional):
ListViewBaseAutomationPeer.GetChildrenCore()now returnsIList<AutomationPeer>instead ofList<AutomationPeer>, which aligns it with WinUI. Code that overrode it withList<AutomationPeer>(an Uno-only workaround) needs to switch toIList<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).