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

Pass stdout to ThrowIfFailed in three runner list methods - #362

Merged
simonrozsival merged 1 commit into
mainfrom
op-fix-runner-throwiffailed-stdout
May 12, 2026
Merged

simonrozsival merged 1 commit into
mainfrom
op-fix-runner-throwiffailed-stdout

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Summary

Three runner list methods captured stdout from their process invocation but didn't pass it to ProcessUtils.ThrowIfFailed, violating the repo convention:

When a method captures stdout, pass it to ProcessUtils.ThrowIfFailed(exitCode, command, stderr, stdout) so failure messages include all output, not just stderr.

For list commands (adb devices -l, avdmanager list avd, emulator -list-avds), the primary diagnostic output on failure goes to stdout, not stderr. Omitting it meant the InvalidOperationException thrown on failure contained only the (possibly empty) stderr, losing the most useful diagnostic information.

Changes

  • AdbRunner.cs (ListDevicesAsync): ThrowIfFailed(exitCode, "adb devices -l", stderr) → ThrowIfFailed(exitCode, "adb devices -l", stderr, stdout)
  • AvdManagerRunner.cs (ListAvdsAsync): ThrowIfFailed(exitCode, "avdmanager list avd", stderr) → ThrowIfFailed(exitCode, "avdmanager list avd", stderr, stdout)
  • EmulatorRunner.cs (ListAvdNamesAsync): ThrowIfFailed(exitCode, "emulator -list-avds", stderr) → ThrowIfFailed(exitCode, "emulator -list-avds", stderr, stdout)

The already-conforming reference is ListReversePortsAsync in AdbRunner.cs, which correctly passes both streams.

Testing

No behavior change on the happy path. Build passes, 145/149 tests pass (4 skipped are pre-existing Windows bash-script skips unrelated to this change).

…AvdNamesAsync

For list commands (adb devices -l, avdmanager list avd, emulator -list-avds),
the primary diagnostic output on failure goes to stdout, not stderr. Omitting
stdout from ThrowIfFailed means the InvalidOperationException contains only the
(possibly empty) stderr, losing the most useful diagnostic.

Follows the convention already used in ListReversePortsAsync (AdbRunner.cs:323).

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings May 8, 2026 21:00

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

Improves diagnostics for Android tool runner “list” commands in Xamarin.Android.Tools.AndroidSdk by ensuring captured stdout is included in failure exceptions via ProcessUtils.ThrowIfFailed, which helps surface the most relevant error output for these commands.

Changes:

  • Pass stdout to ProcessUtils.ThrowIfFailed(...) in AdbRunner.ListDevicesAsync.
  • Pass stdout to ProcessUtils.ThrowIfFailed(...) in AvdManagerRunner.ListAvdsAsync.
  • Pass stdout to ProcessUtils.ThrowIfFailed(...) in EmulatorRunner.ListAvdNamesAsync.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Xamarin.Android.Tools.AndroidSdk/Runners/AdbRunner.cs Includes stdout in failure messages for adb devices -l.
src/Xamarin.Android.Tools.AndroidSdk/Runners/AvdManagerRunner.cs Includes stdout in failure messages for avdmanager list avd.
src/Xamarin.Android.Tools.AndroidSdk/Runners/EmulatorRunner.cs Includes stdout in failure messages for emulator -list-avds.

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge. label May 8, 2026
@simonrozsival
simonrozsival merged commit 8a58f4f into main May 12, 2026
6 checks passed
@simonrozsival
simonrozsival deleted the op-fix-runner-throwiffailed-stdout branch May 12, 2026 14:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants