Repository navigation
fix(automation): Align ListViewBaseAutomationPeer.GetChildrenCore return type with WinUI - #25141
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
…ignature 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
|
Claude finished @MartinZikmund's task in 18s —— View job Review of #25141Verdict: 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. 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.
Housekeeping.
|
|
The build 238473 found UI Test snapshots differences: Details
|
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
|
@Mergifyio backport servicing/6.8 release/stable/6.7 |
✅ Backports have been createdDetails
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
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 |
…6.7/pr-25141 fix(automation): Align ListViewBaseAutomationPeer.GetChildrenCore return type with WinUI (backport #25141)
…r-25141 fix(automation): Align ListViewBaseAutomationPeer.GetChildrenCore return type with WinUI (backport #25141)
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