Skip to content

[WIP] Use shared SimctlOutputParser from Xamarin.MacDev for simctl JSON parsing#24812

Closed
rmarinho wants to merge 6 commits intomainfrom
feature/use-macios-devtools-simctl-parser
Closed

[WIP] Use shared SimctlOutputParser from Xamarin.MacDev for simctl JSON parsing#24812
rmarinho wants to merge 6 commits intomainfrom
feature/use-macios-devtools-simctl-parser

Conversation

@rmarinho
Copy link
Copy Markdown
Member

@rmarinho rmarinho commented Mar 3, 2026

Summary

This PR refactors GetAvailableDevices.RunSimCtlAsync to use the shared SimctlOutputParser from the Xamarin.MacDev submodule (dotnet/macios-devtools) instead of inline JSON parsing.

Plan

We're building shared Apple CLI library APIs in dotnet/macios-devtools to support the maui CLI commands (spec: dotnet/maui#34217). Since macios already uses macios-devtools as a submodule at external/Xamarin.MacDev, we can share the parsing logic between the MSBuild tasks and the CLI tool.

What this PR does

  1. Updates the submodule to include the new SimctlOutputParser and model classes
  2. Replaces inline simctl JSON parsing in RunSimCtlAsync with:
    • SimctlOutputParser.ParseDevices(json) — returns typed SimulatorDeviceInfo objects with UDID, Name, State, IsAvailable, AvailabilityError, Platform, OSVersion
    • SimctlOutputParser.ParseRuntimes(json) — returns typed SimulatorRuntimeInfo objects with SupportedArchitectures
  3. Preserves all business logic — MSBuild metadata, devicetypes lookup, RuntimeIdentifier computation, platform filtering, CanRunArm64

Benefits

  • Tested: The shared parser has 65+ unit tests in macios-devtools
  • Single source of truth: Changes to simctl JSON format only need fixing in one place
  • Shared across tools: Same parser used by both MSBuild tasks and the upcoming maui CLI

Dependencies

Future work

  • Move devicetypes parsing into the shared parser (productFamily, minRuntime, maxRuntime)
  • Add devicectl physical device parsing to the shared parser
  • Add a ParseDeviceTypes method to SimctlOutputParser

cc @rolfbjarne

@rmarinho
Copy link
Copy Markdown
Member Author

rmarinho commented Mar 3, 2026

Updated to use ALL shared parsers — now zero inline JSON parsing remains:

  • SimctlOutputParser.ParseDevices + ParseRuntimes + ParseDeviceTypes
  • DeviceCtlOutputParser.ParseDevices (new)

System.Text.Json and Xamarin.Utils imports removed from GetAvailableDevices.cs.
Net result: -45 lines, 75+ unit tests backing the parsers.

Depends on dotnet/macios-devtools#158 (which now includes ParseDeviceTypes and DeviceCtlOutputParser).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rmarinho rmarinho force-pushed the feature/use-macios-devtools-simctl-parser branch from d76976e to b31f386 Compare March 4, 2026 16:12
@rmarinho rmarinho marked this pull request as ready for review March 4, 2026 16:12
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rmarinho rmarinho force-pushed the feature/use-macios-devtools-simctl-parser branch from b31f386 to 324c76e Compare March 9, 2026 12:40
@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #324c76e] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 324c76e4093b997aae1d89051220962ba2adcbad [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #324c76e] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 324c76e4093b997aae1d89051220962ba2adcbad [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🔥 [CI Build #324c76e] Build failed (Build macOS tests) 🔥

Build failed for the job 'Build macOS tests' (with job status 'Failed')

Pipeline on Agent
Hash: 324c76e4093b997aae1d89051220962ba2adcbad [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 324c76e4093b997aae1d89051220962ba2adcbad [PR build]

rmarinho and others added 6 commits March 9, 2026 15:52
Refactor GetAvailableDevices.RunSimCtlAsync to use the shared
SimctlOutputParser from the Xamarin.MacDev submodule instead of
inline JSON parsing. This:

- Reuses tested parsing logic (65+ unit tests in macios-devtools)
- Shares the parser across both MSBuild tasks and the MAUI CLI tool
- Keeps devicetypes parsing inline (not yet in shared parser)
- Preserves all MSBuild metadata, filtering, and discarding logic

Depends on dotnet/macios-devtools PR #158 being merged to main.
The submodule currently points to feature/simulator-management.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Refactor GetAvailableDevices to use all three shared parsers:
- SimctlOutputParser.ParseDevices: simulator device extraction
- SimctlOutputParser.ParseRuntimes: runtime extraction
- SimctlOutputParser.ParseDeviceTypes: devicetypes extraction
- DeviceCtlOutputParser.ParseDevices: physical device extraction

This eliminates all inline JSON parsing (System.Text.Json and
Xamarin.Utils JsonExtensions no longer needed in this file).
The only remaining code is MSBuild-specific TaskItem mapping,
platform filtering, RuntimeIdentifier computation, and CanRunArm64.

Net result: -45 lines, zero inline JSON parsing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fix NU1605 package downgrade error: Xamarin.MacDev references
System.Text.Json 9.0.4, while Xamarin.MacDev.Tasks pinned 8.0.5.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- XamarinTask: match ICustomLogger nullable signatures (Exception?, object?[])
- GetAvailableDevices: add using Xamarin.Utils for ApplePlatform
- Update submodule to latest (6a2d99b)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AppleSdkSettings was marked [Obsolete] in macios-devtools PR #140
(XcodeLocator). Existing usages in Sdks.cs, CompileAppManifest.cs,
and DetectSdkLocation.cs are intentional pending full migration.
TreatWarningsAsErrors=true promotes the warning to an error.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Point submodule from feature/simulator-management branch to main,
which now includes the merged simulator management APIs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rmarinho
Copy link
Copy Markdown
Member Author

rmarinho commented Mar 9, 2026

Superseded by #24856 — recreated under dev/ branch prefix so CI triggers.

@rmarinho rmarinho closed this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants