Skip to content

Expose gesture recognizer dispatch APIs - #37420

Merged
kubaflo merged 3 commits into
net11.0from
jfversluis-expose-gesture-dispatch-apis
Aug 19, 2026
Merged

kubaflo merged 3 commits into
net11.0from
jfversluis-expose-gesture-dispatch-apis

Conversation

@jfversluis

@jfversluis jfversluis commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

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!

Description of Change

PR #36655 exposed IGesturePlatformManager and IGesturePlatformManagerFactory so third-party backends can participate in gesture lifecycle management. However, the recognizer dispatch methods remained internal, preventing those backends from raising the corresponding commands and events without internal-access workarounds.

This change makes the existing dispatch methods public while preserving their signatures and valid-input behavior. Each method is marked with [EditorBrowsable(EditorBrowsableState.Never)], following the existing DropGestureRecognizer.SendDragOver precedent, and has XML documentation describing its event dispatch, parameters, and return behavior. The newly exposed drag/drop entry points now reject invalid null inputs with ArgumentNullException at the public API boundary; the existing SendDragOver contract is unchanged.

Why no additional interface

IGesturePlatformManager intentionally models lifecycle management only. Dispatch details differ between platform backends, so adding another common interface would introduce an abstraction that does not match the platform-specific implementations. Exposing the existing recognizer hooks provides the required extensibility while preserving the current architecture.

API Changes

  • TapGestureRecognizer.SendTapped
  • PointerGestureRecognizer.SendPointerEntered, SendPointerExited, SendPointerMoved, SendPointerPressed, and SendPointerReleased
  • DragGestureRecognizer.SendDragStarting and SendDropCompleted
  • DropGestureRecognizer.SendDragLeave and SendDrop

The corresponding Controls.Core PublicAPI entries are updated for net, netstandard, Android, iOS, Mac Catalyst, Tizen, and Windows.

LongPressGestureRecognizer.SendLongPressed and SendLongPressing are intentionally excluded. They were introduced independently by #33432 and are not part of the compatibility gap reported in #37338 or the API set assessed for this change; exposing them should receive a separate API review based on a demonstrated third-party backend requirement.

Validation

  • Controls.Core PublicAPI analyzer validation passed for netstandard2.0, netstandard2.1, net11.0, net11.0-ios26.5, net11.0-maccatalyst26.5, and both Windows TFMs.
  • The full gesture recognizer test selection passed: 54 passed, 0 failed.
  • After review changes, targeted drag/drop gesture tests passed: 30 passed, 0 failed, including null-contract coverage.

Issues Fixed

Fixes #37338

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 14, 2026 10:15
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37420

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37420"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Exposes previously-internal gesture recognizer dispatch (“Send*”) methods as public (hidden from IntelliSense via [EditorBrowsable(EditorBrowsableState.Never)]) so third-party gesture backends can raise the corresponding commands/events without relying on internal access.

Changes:

  • Made TapGestureRecognizer.SendTapped and PointerGestureRecognizer.SendPointer* dispatch methods public, adding XML docs and [EditorBrowsable(EditorBrowsableState.Never)].
  • Made DragGestureRecognizer.SendDragStarting / SendDropCompleted and DropGestureRecognizer.SendDragLeave / SendDrop dispatch methods public, adding XML docs and [EditorBrowsable(EditorBrowsableState.Never)].
  • Updated Controls.Core PublicAPI.Unshipped.txt entries across TFMs to reflect the new public surface area.
Show a summary per file
File Description
src/Controls/src/Core/TapGestureRecognizer.cs Exposes SendTapped publicly with docs + EditorBrowsable(Never).
src/Controls/src/Core/PointerGestureRecognizer.cs Exposes pointer dispatch methods publicly with docs + EditorBrowsable(Never).
src/Controls/src/Core/DragAndDrop/DragGestureRecognizer.cs Exposes drag dispatch methods publicly with docs + EditorBrowsable(Never).
src/Controls/src/Core/DragAndDrop/DropGestureRecognizer.cs Exposes drop dispatch methods publicly with docs + EditorBrowsable(Never).
src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt Records new public APIs for netstandard surface.
src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt Records new public APIs for net surface.
src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt Records new public APIs for Android surface.
src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt Records new public APIs for iOS surface.
src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt Records new public APIs for Mac Catalyst surface.
src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt Records new public APIs for Tizen surface.
src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt Records new public APIs for Windows surface.

Review details

  • Files reviewed: 11/11 changed files
  • Comments generated: 0
  • Review effort level: Lite

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 14, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 4 findings

See inline comments for details.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 14, 2026

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please check the ai's suggestions?

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 18, 2026 08:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/Controls/src/Core/DragAndDrop/DragGestureRecognizer.cs:117

  • SendDropCompleted currently validates args only after checking _isDragActive and after setting _isDragActive = false. As a result, SendDropCompleted(null) silently no-ops when no drag is active, and if called with null during an active drag it clears the active-drag flag before throwing, which can mask a subsequent valid completion call. Consider moving the null-check to the start of the method (before the _isDragActive check and before mutating _isDragActive) and adding an <exception cref="ArgumentNullException" ...> doc tag to match the new public boundary behavior.
		[EditorBrowsable(EditorBrowsableState.Never)]
		public void SendDropCompleted(DropCompletedEventArgs args)
		{
			if (!_isDragActive)
			{
				// this is mainly relevant for Android
				// Android fires an Ended action on every single view that has a drop handler
				// but we only need one of those DropCompleted actions to make it through
				return;
			}

			_isDragActive = false;
			_ = args ?? throw new ArgumentNullException(nameof(args));

  • Files reviewed: 13/13 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8a985776-9569-4caf-917c-64051900e5c6
Copilot AI review requested due to automatic review settings August 19, 2026 09:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 13/13 changed files
  • Comments generated: 1
  • Review effort level: Lite

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 19, 2026
@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Aug 19, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 19, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 4 findings

See inline comments for details.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review Summary

@jfversluis — new AI review results are available based on commit 30b3a10.

Gate Passed Confidence Medium Platform Windows


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: WINDOWS · Base: net11.0 · Merge base: ee4d06cd

Test Without Fix (expect FAIL) With Fix (expect PASS)
🧪 DragGestureRecognizerTests DragGestureRecognizerTests ✅ FAIL — 182s ✅ PASS — 61s
🧪 DropGestureRecognizerTests DropGestureRecognizerTests ✅ FAIL — 38s ✅ PASS — 17s
🔴 Without fix — 🧪 DragGestureRecognizerTests: FAIL ✅ · 182s

Error-relevant lines (filtered from the build log):

     at Microsoft.Maui.Controls.Core.UnitTests.DragGestureRecognizerTests.NullDropCompletedArgsDoesNotClearActiveDrag() in /_/src/Controls/tests/Core.UnitTests/Gestures/DragGestureRecognizerTests.cs:line 141
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
     at Microsoft.Maui.Controls.Core.UnitTests.DragGestureRecognizerTests.SendDragStartingThrowsForNullElement() in /_/src/Controls/tests/Core.UnitTests/Gestures/DragGestureRecognizerTests.cs:line 53
     at Microsoft.Maui.Controls.Core.UnitTests.DragGestureRecognizerTests.SendDropCompletedThrowsForNullArgs() in /_/src/Controls/tests/Core.UnitTests/Gestures/DragGestureRecognizerTests.cs:line 123
🟢 With fix — 🧪 DragGestureRecognizerTests: PASS ✅ · 61s

(no coded error found; showing last 1200 chars)

eckBox), result: "True") [2 ms]
  Passed TextPackageCorrectlyExtractedFromCompatibleElement(fieldType: typeof(Microsoft.Maui.Controls.Switch), result: "True") [1 ms]
  Passed TextPackageCorrectlyExtractedFromCompatibleElement(fieldType: typeof(Microsoft.Maui.Controls.Entry), result: "EntryTest") [1 ms]
  Passed TextPackageCorrectlyExtractedFromCompatibleElement(fieldType: typeof(Microsoft.Maui.Controls.Editor), result: "EditorTest") [< 1 ms]
  Passed UserSpecifiedImageIsntOverwritten [7 ms]
[xUnit.net 00:00:01.74]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed PropertySetters [1 ms]
  Passed DropCompletedCommandFiresOnce [3 ms]
  Passed NullDropCompletedArgsDoesNotClearActiveDrag [1 ms]
  Passed HandledTest [2 ms]
  Passed DragStartingCommandFires [< 1 ms]
  Passed SendDragStartingThrowsForNullElement [< 1 ms]
  Passed SendDropCompletedThrowsForNullArgs [< 1 ms]
  Passed UserSpecifiedTextIsntOverwritten [< 1 ms]
  Passed DateTextPackageCorrectlyExtractedFromCompatibleElement(fieldType: typeof(Microsoft.Maui.Controls.DatePicker), result: "12/12/2020 12:00:00 AM") [6 ms]
Test Run Successful.
Total tests: 18
     Passed: 18
 Total time: 2.3403 Seconds
🔴 Without fix — 🧪 DropGestureRecognizerTests: FAIL ✅ · 38s

Error-relevant lines (filtered from the build log):

     at Microsoft.Maui.Controls.Core.UnitTests.DropGestureRecognizerTests.SendDragLeaveThrowsForNullArgs() in /_/src/Controls/tests/Core.UnitTests/Gestures/DropGestureRecognizerTests.cs:line 68
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
     at Microsoft.Maui.Controls.Core.UnitTests.DropGestureRecognizerTests.SendDropThrowsForNullArgs() in /_/src/Controls/tests/Core.UnitTests/Gestures/DropGestureRecognizerTests.cs:line 76
   at Microsoft.Maui.Controls.DropGestureRecognizer.SendDrop(DropEventArgs args) in /_/src/Controls/src/Core/DragAndDrop/DropGestureRecognizer.cs:line 148
🟢 With fix — 🧪 DropGestureRecognizerTests: PASS ✅ · 17s

(no coded error found; showing last 1200 chars)

ype: typeof(Microsoft.Maui.Controls.CheckBox), result: "True") [3 ms]
  Passed TextPackageCorrectlySetsOnCompatibleTarget(fieldType: typeof(Microsoft.Maui.Controls.Entry), result: "EntryTest") [2 ms]
  Passed TextPackageCorrectlySetsOnCompatibleTarget(fieldType: typeof(Microsoft.Maui.Controls.TimePicker), result: "01:00:00") [2 ms]
  Passed TextPackageCorrectlySetsOnCompatibleTarget(fieldType: typeof(Microsoft.Maui.Controls.RadioButton), result: "True") [5 ms]
  Passed TextPackageCorrectlySetsOnCompatibleTarget(fieldType: typeof(Microsoft.Maui.Controls.Label), result: "LabelTest") [< 1 ms]
  Passed TextPackageCorrectlySetsOnCompatibleTarget(fieldType: typeof(Microsoft.Maui.Controls.Editor), result: "EditorTest") [1 ms]
[xUnit.net 00:00:02.41]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed SendDropThrowsForNullArgs [2 ms]
  Passed DateTextPackageCorrectlySetsOnCompatibleTarget(fieldType: typeof(Microsoft.Maui.Controls.DatePicker), result: "12/12/2020 12:00:00 AM") [7 ms]
  Passed DropCommandFires [3 ms]
  Passed PropertySetters [1 ms]
  Passed DragOverCommandFires [< 1 ms]
Test Run Successful.
Total tests: 14
     Passed: 14
 Total time: 3.1244 Seconds
📁 Fix files reverted (11 files)
  • src/Controls/src/Core/DragAndDrop/DragGestureRecognizer.cs
  • src/Controls/src/Core/DragAndDrop/DropGestureRecognizer.cs
  • src/Controls/src/Core/PointerGestureRecognizer.cs
  • src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/TapGestureRecognizer.cs

📋 Pre-Flight — Context & Validation

PR #37420 Pre-Flight

Context

  • Title: Expose gesture recognizer dispatch APIs
  • Base / head: net11.0 / jfversluis-expose-gesture-dispatch-apis
  • Issue: #37338, reported by the Avalonia.Controls.Maui backend. IGesturePlatformManager and its factory are public, but the recognizer dispatch entry points remain internal, so third-party backends cannot raise the matching commands and events without internal-access workarounds.
  • Requested API set: TapGestureRecognizer.SendTapped; all five pointer dispatch methods; DragGestureRecognizer.SendDragStarting and SendDropCompleted; DropGestureRecognizer.SendDragLeave and SendDrop.
  • Platform: Windows.
  • Gate: Already passed: affected tests fail without the fix and pass with it. The gate must not be rerun or overwritten.

Existing PR Approach

The PR changes each existing concrete recognizer dispatch method from internal to public, adds [EditorBrowsable(EditorBrowsableState.Never)] and XML documentation, and records the ten APIs in every Controls.Core PublicAPI.Unshipped.txt surface. It also adds explicit null guards to the drag/drop entry points. In particular, SendDropCompleted(null) now throws before clearing the active-drag flag.

Changed production files:

  • src/Controls/src/Core/TapGestureRecognizer.cs
  • src/Controls/src/Core/PointerGestureRecognizer.cs
  • src/Controls/src/Core/DragAndDrop/DragGestureRecognizer.cs
  • src/Controls/src/Core/DragAndDrop/DropGestureRecognizer.cs
  • Seven src/Controls/src/Core/PublicAPI/*/PublicAPI.Unshipped.txt files

Changed tests:

  • src/Controls/tests/Core.UnitTests/Gestures/DragGestureRecognizerTests.cs
  • src/Controls/tests/Core.UnitTests/Gestures/DropGestureRecognizerTests.cs

Bounded Validation

Use this primary plus affected-regression selection only; do not run the full suite:

dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore --filter "FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.TapGestureRecognizerTests|FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.PointerGestureRecognizerTests|FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.DragGestureRecognizerTests|FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.DropGestureRecognizerTests"

The primary regression assertions are the four new null-contract tests and the active-drag preservation test. The remaining tests in those four affected recognizer classes are the mandatory behavior regressions (the same 54-test gesture selection described by the PR).

Attempt Constraints

Each candidate must use EstablishBrokenBaseline.ps1, modify only paths listed in .github/.baseline-state.json under RevertedFiles, preserve all pre-existing unrelated working-tree changes, perform inline expert self-review, capture all standard try-fix artifacts, and restore with the script before returning. Each candidate gets one implementation/test pass and at most one focused correction/retest.


🔬 Code Review — Deep Analysis

Expert Evaluation — Raw PR #37420

Verdict: Approve with minor changes
Confidence: Medium

The submitted fix correctly exposes the ten requested gesture dispatch entry points, uses EditorBrowsable(Never) for infrastructure-facing APIs, preserves existing valid-input dispatch behavior, and records the new surface in all seven Controls.Core PublicAPI files. The drag/drop null guards are correctly placed before side effects; in particular, invalid SendDropCompleted input no longer clears active-drag state. The added regression test directly protects that state transition.

The single expert review produced four moderate, actionable findings:

  1. DropGestureRecognizer.SendDrop validates inside an async method, so ArgumentNullException is captured in the returned task rather than thrown synchronously. A non-async validating wrapper would make the public argument contract fail fast.
  2. The two newly public DropGestureRecognizer methods are nullable-oblivious because their file disables nullable analysis, despite rejecting null. Their annotations should match the other new non-null public dispatch contracts before shipping.
  3. TapGestureRecognizer.SendTapped publishes a non-null View parameter but does not validate it, allowing commands to run before a null sender reaches event handlers.
  4. All five public pointer dispatch methods have the same non-null sender contract gap, and their infrastructure purpose is less clearly documented than the drag APIs.

These findings do not invalidate the PR's architecture or its existing regression fix, but they can improve the consistency and reliability of the new public API. They therefore justify one consolidated pr-plus-reviewer candidate.

Blast radius: Localized to gesture dispatch entry points; no startup path, shared static state, handler lifecycle, or platform-specific implementation is changed.
External output contract: Not applicable.
Trim/AOT evidence chain: Not applicable.


🛠️ Try-Fix — Analysis & Comparison

Try-Fix Candidate 1 — PR #37420 (issue #37338)

Result: Blocked (environmental — baseline could not be established; no fix was applied or tested)
Platform: windows
Attempt artifacts: CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/attempt-1
Self-review findings count: 0 ([] — no diff to review)

Approach description

Expose the ten gesture dispatch entry points through public infrastructure contract interfaces
that the recognizers implement explicitly
, rather than by widening the visibility of the concrete
methods.

Planned shape (designed in full; not applied — see Failure analysis):

  • Declare four public contracts inside the four recognizer files that the PR already changes (no new
    files, since the allow-list forbids added production files):
    • ITapGestureController in TapGestureRecognizer.cs -> SendTapped
    • IPointerGestureController in PointerGestureRecognizer.cs -> SendPointerEntered, SendPointerExited,
      SendPointerMoved, SendPointerPressed, SendPointerReleased
    • IDragGestureController in DragGestureRecognizer.cs -> SendDragStarting, SendDropCompleted
    • IDropGestureController in DropGestureRecognizer.cs -> SendDragLeave, SendDrop
  • Leave every concrete Send* method internal, exactly as today. Each recognizer implements its
    contract explicitly (DragStartingEventArgs IDragGestureController.SendDragStarting(...) => SendDragStarting(...);),
    a one-line forward per member.
  • A third-party backend (Avalonia.Controls.Maui, issue #37338) casts the recognizer instance it
    already holds: ((IDragGestureController)recognizer).SendDragStarting(view). This solves the
    external-access problem with no InternalsVisibleTo or reflection workaround.
  • Apply the PR's null-argument guards to the internal methods, since they are the behavioral
    contract the affected tests assert: args/element validated before any state mutation, so
    SendDropCompleted(null) throws ArgumentNullException without clearing _isDragActive.
  • Record four interface types plus their eleven interface members in the seven
    PublicAPI.Unshipped.txt surfaces. Explicit interface implementations are not part of the
    implementing type's accessible surface, so no concrete-member entries are added.
    DropGestureRecognizer.cs is #nullable disable, so its entries carry the analyzer's ~
    oblivious marker; the other three files are nullable-enabled and use !/? annotations. Markers
    would be taken from analyzer output, never hand-inferred, per
    .github/instructions/public-api.instructions.md.

Prior approach avoided

Existing PR #37420: flip each of the ten concrete internal dispatch methods to public, suppress
the resulting IntelliSense pollution with [EditorBrowsable(EditorBrowsableState.Never)], add XML
docs, and record ten new concrete members across all seven PublicAPI.Unshipped.txt files (plus
drag/drop null guards). Its root-cause hypothesis is "these members carry the wrong access modifier."

The failure mechanism that hypothesis carries is permanent public-surface inflation on mainstream
types. EditorBrowsable(Never) only hides a member from IntelliSense in consuming assemblies; it
does not remove the member from the type's compile-time or binary surface. So
TapGestureRecognizer.SendTapped, PointerGestureRecognizer.SendPointerMoved, and the rest become
directly callable members of control-facing types that ordinary app authors instantiate every day.
Every future signature change to a dispatch entry point — adding a pointer/device parameter,
changing the getPosition delegate shape — then becomes a binary-breaking change on a mainstream
public type instead of on an infrastructure abstraction. That is not a bug the tests can catch; it
is a durable API-versioning cost the mechanism locks in.

Mechanism-level difference

The difference is the root-cause hypothesis, not the code location — both approaches touch the same
four files.

This approach asserts the actual defect is a missing contract at the gesture-platform boundary,
not a wrong access modifier. Issue #37338 itself reports that IGesturePlatformManager and its
factory are already public and usable — the backend-to-MAUI direction of that boundary is already
expressed as a public abstraction. What does not exist is the corresponding abstraction for the
dispatch direction, so backends fall through to internal-access workarounds. Adding the contract
closes the gap at the same abstraction layer where the rest of the boundary already lives.

Full cause-to-effect chain showing why this avoids the PR's failure mechanism:

  1. Because the dispatch entry points are reached through an interface cast rather than through
    member lookup on the recognizer, the concrete methods can stay internal.
  2. Because they stay internal, the recognizer's own public surface is unchanged, and
    [EditorBrowsable(Never)] becomes unnecessary — the members are genuinely absent from
    IntelliSense and from source-compatible call sites on the concrete type, rather than present but
    cosmetically hidden. The suppression attribute is not needed because there is nothing to suppress.
  3. Because the versioned public surface is now I*GestureController rather than
    TapGestureRecognizer/PointerGestureRecognizer/DragGestureRecognizer/DropGestureRecognizer,
    the compatibility burden lands on deliberately infrastructure-scoped types that only platform
    backends consume. The mainstream control types never acquire the members, so the future-breaking-
    change exposure the PR's mechanism creates never arises.
  4. Because the internal concrete methods are retained and merely forwarded to, the in-repo unit tests
    — which call dragRec.SendDragStarting(null) and dropRec.SendDragLeave(null) directly on the
    concrete types and are not editable — continue to compile unchanged through InternalsVisibleTo.
    An explicit-implementation-only design (moving the bodies onto the interface) would break them,
    because explicit implementations are invisible to member lookup on the concrete type. Retaining
    the internal method as the single implementation body is what makes the mechanism viable here.

Behavior is preserved in both mechanisms: the dispatch bodies are untouched, and the null-guard
placement (validate before mutating _isDragActive) is identical to the PR's, because that placement
is what the affected regression tests pin.

Files changed

None. git diff -- src/Controls/src/Core is empty. The attempt was blocked at Step 2 before the
modification allow-list existed, and skill rule 7 forbids editing tracked files without it.

Complete captured diff

fix.diff (and reviewer-findings.diff) are 0 bytes — there is no attempt-created diff:

Verified after restore: git diff --shortstat -- src/Controls produced no output.

Test command, result, output summary

Command (bounded selection, NOT executed):

dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore --filter "FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.TapGestureRecognizerTests|FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.PointerGestureRecognizerTests|FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.DragGestureRecognizerTests|FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.DropGestureRecognizerTests"

Result: not run. Output summary: none.

The baseline (PR fix reverted) was never established, so HEAD still contains the existing PR fix.
Running the selection would have reported green attributable to the existing PR, not to this
candidate — a false Pass. Per the skill's Pass criteria, a Pass requires the test command to execute
against the attempted fix, so the honest outcome is Blocked. test-output.log records this reason
instead of test output. No other tests, builds, or validation were run; the gate was not rerun and
gate/content.md was not touched.

Self-review

Count: 0 findings (reviewer-findings.json = []). Performed inline against
.github/agents/maui-expert-reviewer.md as required — no sub-agent was spawned, and no child
agents/reviewer/rubber-duck/cross-pollination tasks were launched at any point. With no applied
hunks, the Overarching Principles and the always-active dimensions (Logic and Correctness,
Regression Prevention, Complexity Reduction) have nothing to walk, and no file-path-routed
dimensions match. [] is written as the Step 8 gate requires and reflects the final (empty) diff,
so Step 7.5 detected no drift.

Failure analysis (Blocked)

Blocking cause — environmental, upstream of the fix idea.

pwsh .github/scripts/EstablishBrokenBaseline.ps1 aborted with
ERROR: DIRTY WORKING DIRECTORY - Cannot establish baseline, before detecting fix files and before
writing .github/.baseline-state.json (confirmed absent: Test-Path returned False).

The worktree carries 49 pre-existing modified/deleted tracked files, ~13,353 insertions /
~1,228 deletions, entirely under .github/scripts/, .github/skills/, and eng/scripts/ — e.g.
Review-PR.ps1 (+921), verify-tests-fail.ps1 (+2,236), Run-DeviceTests.ps1 (+823),
Start-Emulator.ps1 (+675), Get-PreviewReadiness.ps1, plus a local 9-line modification to
EstablishBrokenBaseline.ps1 itself adding inflight/* to merge-base candidates.
git diff --ignore-all-space --shortstat still reports ~13,205 insertions, confirming real content
drift rather than CRLF/whitespace noise, so renormalisation would not clear it.

None of those paths belong to PR #37420 — its production files are the four gesture recognizer
sources and seven PublicAPI.Unshipped.txt files. All 49 dirty paths are in fact excluded by the
script's own TestPathPatterns (.github/*) or are eng/scripts infra, yet the gate at line 372
(git status --porcelain --untracked-files=no) throws on any dirty tracked file regardless of
whether it could ever be selected as a fix file.

Why no workaround was taken. The script's param() block exposes only -BaseBranch, -DryRun,
and -Restore — there is no bypass switch. The three remedies it prints each violate a hard
constraint:

  • git checkout -- . destroys ~13k lines of pre-existing work, and git checkout/restore/reset/
    clean/stash are forbidden by the skill's script-only restoration rule and this attempt's bounds.
  • git add . && git commit rewrites HEAD, which would break the git diff HEAD^ HEAD PR-inspection
    contract this attempt depends on and sweep untracked artifacts into a commit in a shared workspace.
  • Retrying without changing anything reproduces the identical failure.

The attempt's bounds also state explicitly that pre-existing unrelated dirty paths must be preserved.
Every escape route therefore breaks a rule, so Blocked is the correct and honest outcome — not a
manufactured Pass and not a destructive workaround.

Impact on the approach itself: none. The blocker is a worktree-state precondition of the baseline
tooling, not a defect in the design. The approach is fully specified above and ready to apply
verbatim once the precondition is met.

Tooling gap worth fixing: EstablishBrokenBaseline.ps1 should scope its dirty-tree gate to paths
that are not already excluded by TestPathPatterns, or expose an explicit opt-out. As written, any
workspace carrying unrelated .github/-or-eng/scripts infra drift — exactly this one — cannot run
a try-fix attempt at all, even though that drift can never be selected as a fix file.

Restoration

Ran exactly pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore (the only permitted
cleanup command). Reported No baseline state found / Restored False, which is the skill's
documented and accepted completion for the verified no-state path: Step 2 reported Blocked before
changing any file, and baseline state was never created. Post-restore git diff -- src/Controls
is empty. All pre-existing unrelated dirty and untracked paths were left exactly as found.


Try-Fix Candidate 2 — PR #37420 (issue #37338)

Result: Blocked (environmental — baseline could not be established; no fix was applied or tested)
Platform: windows
Attempt artifacts: CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/attempt-2
Self-review findings count: 0 ([] — no applied diff to review)

Approach description

Expose the ten gesture dispatch entry points through one public infrastructure-scoped static facade, GestureRecognizerDispatcher, while leaving all concrete recognizer Send* methods internal. The facade would be declared in an existing allow-listed recognizer source because the attempt may not add a production file. It would provide ten static forwarding methods whose first argument is the matching recognizer:

  • SendTapped(TapGestureRecognizer, View, Func<IElement?, Point?>? = null)
  • Five SendPointer* overloads accepting PointerGestureRecognizer and the existing sender, position, platform-event, and button arguments
  • SendDragStarting(DragGestureRecognizer, View, Func<IElement?, Point?>? = null, PlatformDragStartingEventArgs? = null)
  • SendDropCompleted(DragGestureRecognizer, DropCompletedEventArgs)
  • SendDragLeave(DropGestureRecognizer, DragEventArgs)
  • SendDrop(DropGestureRecognizer, DropEventArgs), returning the delegated task

The facade type and methods would carry EditorBrowsable(Never) and infrastructure XML documentation. Each facade method validates its recognizer argument, then forwards into the recognizer's existing internal implementation. The PR's drag/drop null guards remain in those internal implementation bodies, including validation of SendDropCompleted arguments before _isDragActive is cleared. The seven PublicAPI.Unshipped.txt surfaces would record one facade type and ten static members using analyzer-generated nullability markers. Existing in-repo callers and read-only tests keep using the internal concrete methods unchanged.

Prior approaches avoided

PR #37420: directly changes each concrete recognizer method from internal to public, adds EditorBrowsable(Never) and XML documentation, and records those members on four mainstream recognizer types. Its mechanism solves access by widening concrete member visibility. EditorBrowsable(Never) is only discovery suppression; the members remain part of each concrete type's source and binary contract.

Candidate 1: proposed four public infrastructure controller interfaces, explicitly implemented by the recognizers, with forwards to retained internal methods. Its mechanism solves access through an interface cast and adds polymorphic contracts to recognizers. Candidate 1 was Blocked before editing because baseline establishment rejected unrelated dirty infrastructure files; this attempt consumed only its persisted result and did not reopen, modify, rerun, or independently investigate it.

This candidate uses neither direct public concrete dispatch methods nor public controller interfaces.

Mechanism-level difference

The root-cause hypothesis is a missing public dispatch gateway, rather than a wrong concrete access modifier or a missing polymorphic contract. A third-party backend passes the recognizer instance it already owns to GestureRecognizerDispatcher; because the facade is compiled in the Controls assembly, it can invoke the existing internal method. Thus external code reaches dispatch without member lookup on a public recognizer API and without an interface cast.

The cause-to-effect chain is:

  1. Concrete Send* methods remain internal, so app-facing recognizer types do not acquire infrastructure members.
  2. Recognizers implement no new public interfaces, so their type contracts and polymorphic identity remain unchanged.
  3. One purpose-named facade contains the compatibility burden instead of distributing it across four recognizer types or four interfaces.
  4. Internal implementation bodies stay the single source of dispatch behavior, so framework callers and existing tests keep their current call shape.
  5. Drag/drop validation stays inside those bodies and occurs before state mutation, preserving the PR's behavioral correction for invalid arguments.

The facade is a forwarding wrapper by design, but it adds a specific abstraction value: assembly-boundary access while shielding recognizer public surfaces. Compared with candidate 1, it also avoids four interface types and explicit implementation plumbing. Its tradeoff is that the facade's ten method signatures are still public compatibility commitments, but those commitments are centralized on infrastructure rather than mainstream controls.

Files changed

None. The scripted baseline failed before .github/.baseline-state.json or its RevertedFiles allow-list existed. Editing any production path was therefore forbidden.

Complete captured diff

Both fix.diff and reviewer-findings.diff are 0 bytes. The complete candidate-created production diff is:

After the required restore command, git diff --quiet over all four recognizer sources and seven PublicAPI files returned exit code 0.

Exact test command, result, and output summary

The only permitted command was:

dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore --filter "FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.TapGestureRecognizerTests|FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.PointerGestureRecognizerTests|FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.DragGestureRecognizerTests|FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.DropGestureRecognizerTests"

Result: not executed. Output summary: no test-run output exists. test-output.log records why: baseline establishment failed before the candidate could be applied. Running the selection against current HEAD would exercise PR #37420's existing direct-public-method fix and could not provide an attributable candidate-2 Pass. No other build, test, gate, or optional command was run; gate/content.md was not created or overwritten.

Self-review

Count: 0 findings. The inline review used .github/agents/maui-expert-reviewer.md; no child, reviewer, cross-pollination, rubber-duck, final-audit, or expert agent was launched. It covered the eight Overarching Principles, always-active Logic and Correctness, Regression Prevention, and Complexity Reduction, and the relevant Gesture and conditional Public API concerns. The proposed facade's otherwise suspicious forwarding layer is justified by the assembly-boundary and API-isolation value above. Because no code hunk could be applied, there is no concrete file/line defect to record, and reviewer-findings.json correctly contains []. The reviewed and final candidate diffs are both empty, so no refresh drift occurred.

Failure analysis (Blocked)

pwsh .github/scripts/EstablishBrokenBaseline.ps1 exited 1 with ERROR: DIRTY WORKING DIRECTORY - Cannot establish baseline. It listed 49 pre-existing modified or deleted tracked files under .github/scripts, .github/skills, and eng/scripts. These are unrelated to PR #37420 and were preserved exactly as required. The script did not report Baseline established; Test-Path .github/.baseline-state.json returned False.

Without a baseline state, there is no RevertedFiles allow-list. The skill therefore forbids production edits. No destructive workaround was attempted: the unrelated changes were not cleaned, stashed, committed, reset, restored, deleted, or otherwise modified. Retrying the same precondition would not be a focused implementation correction and was outside the hard bounds.

This is an environmental block upstream of the design, not empirical evidence against the static-facade mechanism. The design remains unimplemented and unvalidated, so the result cannot honestly be Pass or Fail.

Restoration

Ran exactly:

pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore

It reported No baseline state found and Restored False. This is the skill-defined accepted restoration outcome for the verified no-state path: baseline failed before edits and no attempt production changes existed. Completion was then verified with .github/.baseline-state.json absent and git diff --quiet returning 0 for all eleven candidate production paths. Every pre-existing unrelated dirty and untracked path was preserved.

Artifact paths

  • CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/attempt-2/baseline.log
  • CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/attempt-2/approach.md
  • CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/attempt-2/reviewer-findings.json
  • CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/attempt-2/reviewer-findings.diff
  • CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/attempt-2/result.txt
  • CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/attempt-2/fix.diff
  • CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/attempt-2/test-output.log
  • CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/attempt-2/analysis.md
  • CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix-2/content.md
  • CustomAgentLogsTmp/PRState/37420/PRAgent/try-fix/content.md

🏁 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Winner: pr-plus-reviewer

pr-plus-reviewer retains the submitted PR's direct, infrastructure-hidden dispatch APIs and its proven drag-state fix, while tightening the new public contracts before they ship. It addresses all four moderate expert findings with one localized patch: synchronous SendDrop argument validation, annotated drop arguments, consistent tap/pointer null guards, infrastructure remarks, and focused contract tests. Its targeted validation was blocked before test execution by a missing project.assets.json; that is uncertainty, not a regression-test failure.

Comparative ranking

Rank Candidate Implementation Regression evidence Assessment
1 pr-plus-reviewer Applied Blocked before execution (NETSDK1004, missing assets) Best API-contract quality. It preserves the PR mechanism and existing behavior while resolving all expert findings. Static patch integrity passed, but the candidate still needs the prescribed test selection after restore.
2 pr Applied Trusted Gate passed; submitted gesture selection reported passing Functionally sound and empirically proven. The expert review found four moderate gaps in the newly public surface: task-captured null validation, nullable-oblivious drop APIs, and inconsistent tap/pointer null contracts.
3 try-fix-2 Not applied Blocked; no tests executed The proposed GestureRecognizerDispatcher facade centralizes infrastructure APIs, but it adds a new public type and forwarding layer without an implementation or empirical evidence.
4 try-fix-1 Not applied Blocked; no tests executed Explicit controller interfaces isolate infrastructure APIs, but four new public contracts and explicit forwarding add the most abstraction and compatibility surface. The design was never implemented or tested.

Expert review of the submitted PR

The raw PR correctly exposes the requested ten dispatch methods, uses EditorBrowsable(Never), updates all seven PublicAPI files, and validates drag/drop inputs before side effects. In particular, SendDropCompleted(null) no longer clears active-drag state, and the added regression test protects that transition. No blocking logic, lifecycle, threading, platform, trimming, or performance defect was found.

The four inline findings are persisted in inline-findings.json. They are moderate rather than crash-level regressions, but they concern contracts that become difficult to correct after shipping. Applying them now is preferable to approving the raw API surface unchanged.

Failure-mode comparison

  • Null sender: raw pr can execute a command and then deliver a null sender to tap/pointer handlers; pr-plus-reviewer rejects the call before side effects.
  • Unobserved async call: raw pr captures SendDrop(null) in a faulted task; pr-plus-reviewer throws before returning the task.
  • Nullable consumers: raw pr publishes the drop APIs as nullable-oblivious; pr-plus-reviewer exposes explicit non-null contracts consistent with runtime validation.
  • Valid dispatch and lifecycle: neither candidate changes handler connection, platform routing, shared state, startup behavior, or valid-input event/command ordering.

No try-fix-* candidate passed regression tests; both were blocked before producing code. The raw PR's trusted Gate passed. The winner is nevertheless pr-plus-reviewer because its validation attempt was environmentally blocked rather than failed and its delta is a focused strengthening of the same proven fix.

Prior review and CI reconciliation

The earlier MauiBot review contained four moderate findings, not ❌ Error-level findings. Current submitted HEAD addresses all four: drag/drop arguments are guarded, drag lifecycle pairing is documented, and the description explicitly explains the long-press exclusion. No unresolved prior ❌ finding was found across top-level reviews, inline comments, or issue comments.

Anonymous current-head check data shows maui-pr, Build Analysis, Windows/macOS builds, packs, Helix unit tests, and listed integration tests completed successfully; only the unrelated Bump global.json check was skipped. Because authenticated gh pr checks --required was unavailable and GitHub's combined legacy status remained pending without reported status contexts, formal required-check classification is undetermined. This does not alter the REQUEST CHANGES result, which is driven by the winning candidate.


📱 UI Tests — Gestures

Detected UI test categories: Gestures

[!WARNING]
No UI test results were produced for the detected categories. The PR build itself was
fine — the deep UI stage was skipped or interrupted on infrastructure (the
merge-for-testing step, emulator/simulator boot, or an Appium hang), not by this PR's code.
This is usually transient; the review re-runs on new commits (a maintainer can also re-run it).


🧭 Next Steps — reviewer patch required (pr-plus-reviewer)

The reviewer-enhanced candidate won, so the submitted PR still needs those changes.

Why: The reviewer-enhanced PR preserves the submitted fix and its proven drag-state behavior while resolving four moderate public-contract gaps. Its targeted test command was blocked before execution by missing restored assets, so the recommendation records validation uncertainty rather than a regression failure.

Apply PRAgent/pr-plus-reviewer/reviewer.patch from the CopilotLogs
artifact (or follow the report's Required submitted-PR change), push the update, and run
the review again.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 19, 2026
@kubaflo
kubaflo merged commit 62418a4 into net11.0 Aug 19, 2026
36 checks passed
@kubaflo
kubaflo deleted the jfversluis-expose-gesture-dispatch-apis branch August 19, 2026 22:45
@github-actions github-actions Bot added this to the .NET 11.0-preview7 milestone Aug 19, 2026
kubaflo added a commit that referenced this pull request Aug 22, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Follow-up to #37420, which exposed gesture recognizer dispatch hooks for
third-party `IGesturePlatformManager` implementations.

This change hardens the newly public contract based on post-merge review
feedback:

- Validates required `sender` inputs before command or event dispatch
for tap and all pointer dispatch methods.
- Makes `DropGestureRecognizer.SendDrop` validate synchronously before
returning its processing task, so fire-and-forget callers still receive
an immediate `ArgumentNullException`.
- Publishes `SendDragLeave` and `SendDrop` with non-nullable parameter
and return annotations across every Controls.Core PublicAPI TFM.
- Clears stale active-drag state when a replacement drag starts,
including when that replacement is canceled or handled.
- Documents the infrastructure-only intent and exception behavior
consistently.

The existing public `DropGestureRecognizer.SendDragOver` behavior is
intentionally unchanged.

### Validation

- Controls.Core gesture tests: 62 passed, 0 failed.
- PublicAPI validation passed for `net11.0`, `netstandard2.0`,
`netstandard2.1`, `net11.0-ios26.5`, `net11.0-maccatalyst26.5`, and both
Windows TFMs.
- Android validation is locally blocked by the unavailable Android API
37 SDK platform; its PublicAPI entries use the same analyzer-derived
shared declarations. Tizen is not included in the local target framework
set and uses the same declarations.

### Issues Fixed

Follow-up to #37338 and #37420.

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8a985776-9569-4caf-917c-64051900e5c6
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Redth added a commit to Redth/Maui.Tizen that referenced this pull request Aug 26, 2026
dotnet/maui#37420 and #37671 made most of the gesture dispatch surface public.
Measured by reflecting over the shipped assemblies rather than reading source:

  11.0.0-preview.7.26418.3   Tap (none)  Pointer (none)  LongPress (none)
  11.0.0-preview.7.26426.4   Tap SendTapped
                             Pointer SendPointerEntered/Exited/Moved/Pressed/Released
                             LongPress (none)

So the package pin moves from 26418.3 to 26426.4 (nuspec commit bedd1b18b7). All seven
MAUI packages were confirmed present at that stamp before bumping, and the pin is kept
in sync in eng/baselines.json as that file requires.

Tap and pointer now dispatch for real. Long press is the only gesture this backend can
detect but not raise: SendLongPressed and SendLongPressing are still internal, with no
ILongPressGestureController alternative. That is now stated as exactly two named members
rather than a blanket "tap, long-press and pointer are blocked".

Drag and drop also changed reason. Their dispatch members are public as of 26426.4, so
they are no longer dispatch-blocked - they remain unsupported purely because NUI has no
view-level drag/drop that maps onto the per-view recognizer semantics. The matrix now
says so.

Position resolution
-------------------
The new members take Func<IElement?, Point?> rather than a point, so MAUI can ask for a
position relative to an arbitrary element. The Tizen detectors report a view-local
position, which is returned for the view itself and for the null request. For any other
element the resolver returns null - MAUI's own encoding of "cannot be determined" -
because translating between two elements needs both on-screen origins, which requires a
native call per element that the Tizen platform layer does not expose here. A
plausible-looking wrong coordinate would be worse.

PlatformPointerEventArgs is left null and ButtonsMask at its default. Both are optional,
and NUI reports neither for touch and hover, so fabricating them would mislead.

Testing
-------
158 tests, up from 150. The dispatcher tests use real recognizers, so they prove the
public path delivers events rather than merely compiling; verified by stubbing the
SendTapped call out and watching three tests fail.

LongPressSendMembersAreStillInternalUpstream asserts by reflection that the two named
members are absent from BindingFlags.Public and present under NonPublic, so the support
matrix's central claim cannot rot. It fails when upstream opens the API.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo pushed a commit that referenced this pull request Aug 27, 2026
…tform backends (#37861)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

External platform backends can already raise tap and pointer gestures,
because #37420 / #37671 made `TapGestureRecognizer.SendTapped` and the
`PointerGestureRecognizer.Send*` methods public infrastructure APIs.
`LongPressGestureRecognizer.SendLongPressing` / `SendLongPressed` were
left `internal`, so an out-of-tree backend can detect a long press but
has **no supported way to dispatch it**.

Concrete blocker:
[Redth/Maui.Tizen#9](Redth/Maui.Tizen#9) has to
no-op its long press dispatch.

This PR promotes both methods to `public` with
`[EditorBrowsable(EditorBrowsableState.Never)]` and an
`ArgumentNullException` guard on `sender` — the smallest additive
surface, patterned exactly on the existing tap/pointer dispatch APIs:

```csharp
[EditorBrowsable(EditorBrowsableState.Never)]
public void SendLongPressed(View sender, Func<IElement?, Point?>? getPosition = null);

[EditorBrowsable(EditorBrowsableState.Never)]
public void SendLongPressing(View sender, GestureStatus status, Func<IElement?, Point?>? getPosition = null);
```

A `public ILongPressGestureController` was considered and rejected: no
other recognizer added in this wave uses a controller interface, so an
interface would be inconsistent with `SendTapped` / `SendPointer*` and
would add a second dispatch shape for backend authors to learn.

**Nothing else changes.** Command execution (including `CanExecute`),
event raising, `GestureStatus` Started/Running/Completed/Canceled
transitions, `State` updates, the lazy `getPosition` callback contract,
touch-count filtering, cancellation semantics, threading expectations,
and every in-box platform call site (iOS/MacCatalyst, Android, Windows,
Tizen) are untouched. Widening accessibility has no trimming impact, and
`LongPressGestureRecognizer` is entirely unshipped API in `net11.0`, so
this is purely additive.

### Reproducing the failure

Added `src/Controls/tests/ExternalGestureBackend`, a test-support
assembly that is **deliberately excluded** from
`Microsoft.Maui.Controls`' `InternalsVisibleTo` list. Before the fix it
fails to build:

```
error CS1061: 'LongPressGestureRecognizer' does not contain a definition for 'SendLongPressing' ...
error CS1061: 'LongPressGestureRecognizer' does not contain a definition for 'SendLongPressed' ...
```

It now compiles, and its `FakeLongPressGestureBackend` drives the
recognizer purely through the public API. Demoting either method back to
`internal` breaks that project's build — the contract is enforced by the
build, not just by convention.

### Tests

New `LongPressGestureRecognizerExternalBackendTests`
(Controls.Core.UnitTests) drives the fake external backend:

- Full `Started` → `Running` → `Completed` lifecycle, and `LongPressed`
ordering *before* `Completed`
- `Canceled` raises no `LongPressed` and executes no command
- Cancellation when movement exceeds `AllowableMovement`
- Command dispatch with `CommandParameter`, and `CanExecute == false`
suppression
- Sender identity + `getPosition` relative-to-element behavior
- `NumberOfTouchesRequired` filtering, and fan-out to every matching
recognizer on the view
- Reflection guard asserting both methods are `public` and
`[EditorBrowsable(Never)]`

Also added `SendLongPressed_ThrowsForNullSender` /
`SendLongPressing_ThrowsForNullSender` to the existing
`LongPressGestureRecognizerTests`, matching
`TapGestureRecognizerTests.SendTappedThrowsForNullSender`.

**Results:** `Controls.Core.UnitTests` — 6219 passed, 0 failed, 30
skipped (includes the pre-existing `LongPressGestureRecognizerTests` and
`LongPressGestureRecognizerPerformanceTests`). `dotnet build
src/Controls/src/Core/Controls.Core.csproj -p:PublicApiType=Validate -f
net11.0` succeeds with 0 warnings; removing an entry from
`PublicAPI.Unshipped.txt` correctly fails with `RS0016`, confirming the
analyzer is enforcing the new signatures.

No device tests exist for `LongPressGestureRecognizer`; platform
behavior stays covered by the existing `LongPressGestureInteraction` UI
test, which is unaffected.

### Docs

Added `docs/design/GestureDispatchForPlatformBackends.md` for backend
authors: the full dispatch table across all recognizers, the shared
rules (non-null sender, UI thread, lazy `getPosition` semantics,
honoring recognizer configuration), the exact long press call ordering
used by each in-box platform, and a complete example backend.

### PublicAPI

Added the two entries to all seven `src/Controls/src/Core/PublicAPI/*`
TFM folders (`net`, `net-android`, `net-ios`, `net-maccatalyst`,
`net-tizen`, `net-windows`, `netstandard`).

### Issues Fixed

Unblocks external platform backends (e.g.
[Redth/Maui.Tizen#9](Redth/Maui.Tizen#9)) from
dispatching long press gestures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants