Skip to content

[ci-fix] Fix IL2009 AOT trim warning from CustomPressGestureRecognizer ObjC registration-name collision - #36101

Closed
github-actions[bot] wants to merge 1 commit into
net11.0from
ci-fix/issue-36081-attempt-1-459dba0c69bd89a9
Closed

[ci-fix] Fix IL2009 AOT trim warning from CustomPressGestureRecognizer ObjC registration-name collision#36101
github-actions[bot] wants to merge 1 commit into
net11.0from
ci-fix/issue-36081-attempt-1-459dba0c69bd89a9

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

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

🟡 Help wanted — candidate fix, not yet runner-validated. This draft was produced by the automated CI-failure fixer. The change is a well-reasoned candidate, but it could not be validated on the workflow runner (Linux, no Apple workloads → the iOS/MacCatalyst full-trim AOT template test cannot be built or published here). A maintainer with an iOS/MacCatalyst trim-capable environment should validate before merge.

Problem

The maui-pr AOT/trimming template test (full-trim publish of a net11.0-maccatalyst / net11.0-ios template app) fails on net11.0 because the trimmer writes an unexpected linker-warning file. The warning is:

IL2009: Could not find method 'Activated(T)' on type 'UIKit.UIGestureRecognizer.Callback`1'

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 into apply-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.Callback registers its Objective-C class name as __UIGestureRecognizer:

[Register("__UIGestureRecognizer")]
class Callback : Token

That is the same Objective-C class name the Microsoft.iOS SDK uses for its own internal UIKit.UIGestureRecognizer.Callback token type. Because two managed types claim the identical native registration name, the [Preserve(Conditional = true)] attribute on MAUI's Activated(UIGestureRecognizer) produces a preserve descriptor whose declaring type — when the linker resolves it by registered name — binds to the SDK's generic UIGestureRecognizer.Callback\1. That token type has no Activated(T)member in the current SDK, so the descriptor is unresolvable →IL2009`.

Fix

Give MAUI's nested Callback a unique registration name. The preserve descriptor then resolves to MAUI's own type, whose Activated(UIGestureRecognizer) exists, so no warning is generated:

[Register("Microsoft_Maui_Controls_Platform_iOS_CustomPressGestureRecognizer_Callback")]
class Callback : Token

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 the target: selector ([Export("target:")]), not by class name, and MAUI always instantiates its own Callback, so the rename does not change runtime behavior. The change is a single line in src/Controls/src/Core/Platform/iOS/CustomPressGestureRecognizer.cs and 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/ios full-trim template, so it cannot confirm the warning is gone. To validate:

  • Run the AOT template integration test that publishes a fully-trimmed net11.0-maccatalyst (and net11.0-ios) app and asserts no unexpected warning files (Microsoft.Maui.IntegrationTests, AOT category), or
  • dotnet publish -f net11.0-maccatalyst -c Release a minimal MAUI app with full trimming enabled and confirm no IL2009 referencing UIGestureRecognizer.Callback appears.

Alternative considered

Removing the now-arguably-redundant [Preserve(Conditional = true)] on Activated (the [Export]ed member of a registrar-rooted NSObject is 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)

Generated by CI Failure Fixer (net11.0) · 2.7K AIC · ⌖ 71.1 AIC · ⊞ 66.9K ·

…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
@PureWeen

PureWeen commented Jul 1, 2026

Copy link
Copy Markdown
Member

Closing as superseded. The only change in this PR — renaming the ObjC registration name on CustomPressGestureRecognizer from __UIGestureRecognizer to a unique callback name — already landed in main via #36125 ("Fix AOT trim warnings on net11.0", merged 2026-06-26), which touches the same file and additionally fixes BuildWarningsUtilities.cs and the [Preserve] attribute. This bot PR is now redundant. Tracking issue #36081 should be verified against #36125.

Closed by the CI-fix triage sweep.

@PureWeen PureWeen closed this Jul 1, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant