[ci-fix] Fix IL2009 AOT trim warning from CustomPressGestureRecognizer ObjC registration-name collision - #36101
Closed
github-actions[bot] wants to merge 1 commit into
Closed
Conversation
…r.Callback ObjC name collision The nested Callback type registered its Objective-C class as "__UIGestureRecognizer", the same name the Microsoft.iOS SDK uses for its own internal UIGestureRecognizer.Callback token type. The duplicate registration makes the [Preserve(Conditional = true)] descriptor emitted into apply-preserve-attribute.xml resolve against the SDK type, whose Activated(T) signature no longer exists in the current SDK, producing: IL2009: Could not find method 'Activated(T)' on type 'UIKit.UIGestureRecognizer.Callback`1' Giving MAUI's Callback a unique registration name removes the collision so the preserve descriptor resolves to MAUI's own Activated(UIGestureRecognizer), which exists. Refs: #36081
3 tasks
This was referenced Jun 24, 2026
Closed
Member
|
Closing as superseded. The only change in this PR — renaming the ObjC registration name on Closed by the CI-fix triage sweep. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Target branch: net11.0
Problem
The
maui-prAOT/trimming template test (full-trim publish of anet11.0-maccatalyst/net11.0-iostemplate app) fails on net11.0 because the trimmer writes an unexpected linker-warning file. The warning is:Verified to still reproduce against the latest completed
maui-pr(definition 302) net11.0 build (build #1477477 — present across many RIDs in the failed-leg logs). The warning is emitted intoapply-preserve-attribute.xml, and the AOT-warnings test infra (BuildWarningsUtilities.AssertWarnings, which carries an empty iOS/MacCatalyst native-AOT warning baseline) treats the presence of any warning file as "Unexpected warning files detected!", failing the test.Root cause
CustomPressGestureRecognizer.Callbackregisters its Objective-C class name as__UIGestureRecognizer:That is the same Objective-C class name the Microsoft.iOS SDK uses for its own internal
UIKit.UIGestureRecognizer.Callbacktoken type. Because two managed types claim the identical native registration name, the[Preserve(Conditional = true)]attribute on MAUI'sActivated(UIGestureRecognizer)produces a preserve descriptor whose declaring type — when the linker resolves it by registered name — binds to the SDK's genericUIGestureRecognizer.Callback\1. That token type has noActivated(T)member in the current SDK, so the descriptor is unresolvable →IL2009`.Fix
Give MAUI's nested
Callbacka unique registration name. The preserve descriptor then resolves to MAUI's own type, whoseActivated(UIGestureRecognizer)exists, so no warning is generated:This also removes a latent duplicate Objective-C class registration (two managed types registering
__UIGestureRecognizer), which is incorrect on its own. The callback is dispatched through thetarget:selector ([Export("target:")]), not by class name, and MAUI always instantiates its ownCallback, so the rename does not change runtime behavior. The change is a single line insrc/Controls/src/Core/Platform/iOS/CustomPressGestureRecognizer.csand touches no test or assertion.Why help-wanted / how to validate
The fixer runs on Linux without Apple workloads and cannot build or publish the
maccatalyst/iosfull-trim template, so it cannot confirm the warning is gone. To validate:net11.0-maccatalyst(andnet11.0-ios) app and asserts no unexpected warning files (Microsoft.Maui.IntegrationTests, AOT category), ordotnet publish -f net11.0-maccatalyst -c Releasea minimal MAUI app with full trimming enabled and confirm noIL2009referencingUIGestureRecognizer.Callbackappears.Alternative considered
Removing the now-arguably-redundant
[Preserve(Conditional = true)]onActivated(the[Export]ed member of a registrar-rootedNSObjectis already a static-registrar root under full trimming) would also stop the descriptor from being generated. The rename was preferred because it fixes the underlying native-name collision rather than only suppressing its symptom, and it keeps the explicit preservation intent.Refs: #36081
Attempt: 1/5
Flake-class: n/a (hard, deterministic failure — reproduces every recent net11.0 build)