Add AvdManagerRunner.ListDeviceProfilesAsync() for device profile enumeration#325
Add AvdManagerRunner.ListDeviceProfilesAsync() for device profile enumeration#325
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class support in Xamarin.Android.Tools.AndroidSdk for enumerating AVD device profiles (hardware definitions) by running avdmanager list device, returning strongly-typed results for consumers (IDE extensions, GUI tools, CLIs).
Changes:
- Introduced
AvdDeviceProfilerecord model (Id,Name,Oem,Tag). - Added
AvdManagerRunner.ListDeviceProfilesAsync()plusParseDeviceListOutput()to parseavdmanager list deviceoutput. - Added unit tests for parsing behavior across multiple profiles, empty/header-only output, missing name fallback, and Windows newlines; updated PublicAPI unshipped entries for both TFMs.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Xamarin.Android.Tools.AndroidSdk-Tests/AvdManagerRunnerTests.cs | Adds parsing-focused unit tests for device profile enumeration. |
| src/Xamarin.Android.Tools.AndroidSdk/Runners/AvdManagerRunner.cs | Implements the new API to run avdmanager list device and parse results. |
| src/Xamarin.Android.Tools.AndroidSdk/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt | Declares the new public API surface for netstandard2.0. |
| src/Xamarin.Android.Tools.AndroidSdk/PublicAPI/net10.0/PublicAPI.Unshipped.txt | Declares the new public API surface for net10.0. |
| src/Xamarin.Android.Tools.AndroidSdk/Models/AvdDeviceProfile.cs | Adds the new public model type representing a device profile. |
02bb295 to
8b87399
Compare
This comment was marked as outdated.
This comment was marked as outdated.
| /// <summary> | ||
| /// Lists available device profiles (hardware definitions) using <c>avdmanager list device --compact</c>. | ||
| /// </summary> | ||
| public async Task<IReadOnlyList<AvdDeviceProfile>> ListDeviceProfilesAsync (CancellationToken cancellationToken = default) | ||
| { |
| /// <summary> | ||
| /// Represents a hardware device profile (e.g., "pixel_7", "Nexus 5X") from <c>avdmanager list device --compact</c>. | ||
| /// </summary> | ||
| public record AvdDeviceProfile (string Id); |
| Xamarin.Android.Tools.AvdManagerRunner.ListDeviceProfilesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Xamarin.Android.Tools.AvdDeviceProfile!>!>! | ||
| Xamarin.Android.Tools.AvdDeviceProfile | ||
| Xamarin.Android.Tools.AvdDeviceProfile.AvdDeviceProfile(string! Id) -> void | ||
| Xamarin.Android.Tools.AvdDeviceProfile.Id.get -> string! | ||
| Xamarin.Android.Tools.AvdDeviceProfile.Id.init -> void |
| Xamarin.Android.Tools.AvdManagerRunner.ListDeviceProfilesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Xamarin.Android.Tools.AvdDeviceProfile!>!>! | ||
| Xamarin.Android.Tools.AvdDeviceProfile | ||
| Xamarin.Android.Tools.AvdDeviceProfile.AvdDeviceProfile(string! Id) -> void | ||
| Xamarin.Android.Tools.AvdDeviceProfile.Id.get -> string! | ||
| Xamarin.Android.Tools.AvdDeviceProfile.Id.init -> void |
…meration Add ListDeviceProfilesAsync() and ParseDeviceListOutput() to AvdManagerRunner. Runs 'avdmanager list device' and parses the output into AvdDeviceProfile records (Id, Name, Oem, Tag). Includes AvdDeviceProfile record model, 6 unit tests, and PublicAPI entries for both net10.0 and netstandard2.0. Closes #321 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8b87399 to
ca2c633
Compare
|
/review |
|
✅ Android Tools PR Reviewer completed successfully! |
The gh-aw safe_outputs framework requires at least one create_pull_request_review_comment before submit_pull_request_review will work. When the reviewer gives a clean LGTM with no inline comments, the review silently fails with "No review context set." Update the workflow prompt and SKILL.md to require at least one inline comment on every review, even for clean PRs. ### Example - PR that triggered the bug: #325 - Broken workflow run: https://github.com/dotnet/android-tools/actions/runs/25168175699 - See the `safe_outputs` → `Process Safe Outputs` step: `"Submitting PR review (body-only, no inline comments)"` → `"No review context set - cannot submit review"` - Completion comment (with no actual review posted): #325 (comment) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/review |
|
✅ Android Tools PR Reviewer completed successfully! |
There was a problem hiding this comment.
✅ LGTM — Clean, well-structured addition
Summary: Adds ListDeviceProfilesAsync() to AvdManagerRunner and a companion AvdDeviceProfile record, with solid test coverage.
Positives:
- Follows existing patterns exactly:
ProcessUtils.CreateProcessStartInfo,StartProcess,ThrowIfFailed, logger invocation — mirrorsListAvdsAsyncandDeleteAvdAsync. AvdDeviceProfileis a positionalrecordin its own file underModels/— matchesAvdInfo,SdkPackage, etc.- Parser is
internal staticfor testability without exposing implementation detail. - Return type is
IReadOnlyList<T>— correct per API design conventions. ThrowIfFailedincludes bothstderrandstdout— actually improves on the olderListAvdsAsyncpattern.- PublicAPI files updated for both
net10.0andnetstandard2.0. - Tests cover multiple profiles, empty output, Windows
\r\nnewlines, blank lines, and return type — good coverage. initaccessor onnetstandard2.0works via the existingIsExternalInit.cspolyfill.
CI: license/cla ✅ passed. No build/test CI runs visible on this check — ensure the full build pipeline passes before merge.
No issues found. One 💡 observation posted inline about a positive pattern worth backporting.
Generated by Android Tools PR Reviewer for issue #325 · ● 1.6M
| logger.Invoke (TraceLevel.Verbose, "Running: avdmanager list device --compact"); | ||
| var exitCode = await ProcessUtils.StartProcess (psi, stdout, stderr, cancellationToken, environmentVariables).ConfigureAwait (false); | ||
|
|
||
| ProcessUtils.ThrowIfFailed (exitCode, "avdmanager list device --compact", stderr, stdout); |
There was a problem hiding this comment.
🤖 💡 Pattern — Nice: passing both stderr and stdout to ThrowIfFailed follows the recommended convention for including all output in error diagnostics. Worth noting that the existing ListAvdsAsync (line 46) only passes stderr — a follow-up PR could bring it in line with this improved pattern.
Rule: Include stdout in error diagnostics (Postmortem #48)
Summary
Add a method to enumerate available AVD device profiles (hardware definitions) using
avdmanager list device --compact.Uses the
--compactflag for clean, script-friendly output (one device ID per line) instead of the verbose multi-line format.Changes
AvdDeviceProfilerecord (Id) inModels/AvdManagerRunner.ListDeviceProfilesAsync()— runsavdmanager list device --compactand parses outputParseCompactDeviceListOutput()static method for testabilityPublicAPI.Unshipped.txtfor bothnet10.0andnetstandard2.0Closes #321