Repository navigation
[release/10.0.1xx] [UIKit] Fix UIScreenEdgePanGestureRecognizer(Action<UIScreenEdgePanGestureRecognizer>) constructor. Fixes #27066 - #27391
Open
rolfbjarne wants to merge 1 commit into
Conversation
…estureRecognizer>)` constructor. Fixes #27066 (#27079) `UIPanGestureRecognizer`'s internal constructor (IntPtr sel, Token token) was passing (token, sel) to its base constructor instead of (sel, token), resolving to `UIGestureRecognizer(NSObject, IntPtr)` instead of `UIGestureRecognizer(IntPtr, Token)`. As a result, the callback token for `UIScreenEdgePanGestureRecognizer(Action<T>)` was never stored in the recognizers dictionary or marked dirty, allowing it to be garbage collected before the gesture action could be invoked. Fixes #27066 🤖 Pull request created by Copilot --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Rolf Bjarne Kvinge <rokvin@microsoft.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The test keeps the recognizer strongly referenced, so it cannot detect a missing MarkDirty() call that could leave the managed peer and callback collectible; it should also assert the registered-toggle-reference flag.
1 open issue
What changed in this PR
Backports #27079 to release/10.0.1xx, fixing lost UIScreenEdgePanGestureRecognizer constructor callbacks in the UIKit bindings (#27066).
Changes:
- Corrects constructor argument order so callback tokens are retained and
MarkDirty()is called. - Adds a non-tvOS regression test for target registration and callback delivery after garbage collection.
| File | Description |
|---|---|
tests/monotouch-test/UIKit/GestureRecognizerTest.cs |
Adds screen-edge pan callback regression coverage. |
src/UIKit/UIGestureRecognizer.cs |
Routes the internal pan constructor through the token-tracking base overload. |
Review effort: Balanced
| }; | ||
|
|
||
| using var recognizer = new UIScreenEdgePanGestureRecognizer (callback); | ||
| Assert.That (recognizer.GetTargets (), Is.Not.Empty, "GetTargets"); |
dalexsoto
approved these changes
Nov 19, 2026
This branch has not been deployed
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.

UIPanGestureRecognizer's internal constructor (IntPtr sel, Token token) waspassing (token, sel) to its base constructor instead of (sel, token), resolving
to
UIGestureRecognizer(NSObject, IntPtr)instead ofUIGestureRecognizer(IntPtr, Token).As a result, the callback token for
UIScreenEdgePanGestureRecognizer(Action<T>)was never stored in the recognizers dictionary or marked dirty, allowing it to
be garbage collected before the gesture action could be invoked.
Fixes #27066
🤖 Pull request created by Copilot
Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com
Co-authored-by: Rolf Bjarne Kvinge rokvin@microsoft.com
Backport of #27079.