Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Add AdbRunner forward port management APIs (mirror of #305 reverse) #350

Description

@rmarinho

Summary

Add forward port management APIs to Xamarin.Android.Tools.AdbRunner, mirroring the reverse-port API added in #305. adb forward is sometimes the right primitive for hot-reload tunnels (ServiceHub forwardPort), and is needed by the MAUI DevTools CLI as a sibling of the existing reverse-port surface.

Context

The MAUI DevTools CLI exposes a maui android port group for tunnel management. Reverse forwarding (reverse <local> <remote>) is already mappable via #305's ReversePortAsync. But forward forwarding (forward <local> <remote>, where local is on the host machine and remote is on the device) is the opposite primitive — used when something on the host needs to talk to a service running on the device.

Today we have to fall back to raw adb forward … invocations. See maui-labs#197 audit.

Proposed API

Mirrors the reverse-port API surface added in #305 for symmetry.

namespaceXamarin.Android.Tools;publicpartialclassAdbRunner{/// adb -s <serial> forward <local> <remote>publicvirtualTaskForwardPortAsync(stringserial,AdbPortSpeclocal,AdbPortSpecremote,CancellationTokencancellationToken=default);/// adb -s <serial> forward --remove <local>publicvirtualTaskRemoveForwardPortAsync(stringserial,AdbPortSpeclocal,CancellationTokencancellationToken=default);/// adb -s <serial> forward --remove-allpublicvirtualTaskRemoveAllForwardPortsAsync(stringserial,CancellationTokencancellationToken=default);/// adb -s <serial> forward --list (returns rules for the matching serial)publicvirtualTask<IReadOnlyList<AdbPortRule>>ListForwardPortsAsync(stringserial,CancellationTokencancellationToken=default);}

The existing AdbPortSpec and AdbPortRule types from #305 are reused — both forward and reverse use the same tcp:, localabstract:, localreserved:, localfilesystem:, dev:, jdwp: syntax.

adb forward --list global output (no serial filter) is emitted by adb as <serial> <local> <remote> per line. Filter to the requested serial in the implementation, matching the symmetry with ListReversePortsAsync.

Consumer

  • MAUI DevTools CLI (dotnet/maui-labs) — maui android port forward <local> <remote> [--device], maui android port forward --remove, --list, --clear-all. See maui-labs#197 audit.
  • VS Code MAUI extension ServiceHub → CLI migration — MauiAndroidPlatform.tsforwardPort() (used in some debugger configurations where the IDE host needs to connect to a device-side socket).
  • DevFlow agent connect flow — when the agent listens on a device port and the host needs to reach it via a stable host-side port (alternative to the current reverse pattern).

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions