Skip to content

Add VS Code resource debugging for .NET and Go - #18602

Merged
Ella Hathaway (ellahathaway) merged 127 commits into
microsoft:mainfrom
adamint:adamint/issue18538-vscode-debug-shortcut
Oct 29, 2026
Merged

Ella Hathaway (ellahathaway) merged 127 commits into
microsoft:mainfrom
adamint:adamint/issue18538-vscode-debug-shortcut

Conversation

@adamint

@adamint Adam Ratzman (adamint) commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds resource debugger attachment for running .NET and Go resources from the Aspire view and the aspire_resource_debug Copilot tool.

Fixes #18538.
Fixes #18937.

What changed

  • Adds a shared resource-debug service, provider registry, session registry, and safe result contract for tree and language-model callers.
  • Adds .NET and Go attach providers.
  • Resolves the launched application instead of attaching to dotnet run, dotnet watch, or go run. Process discovery supports Windows, macOS, and Linux.
  • Uses kernel-backed executable identity on macOS and exact executable identity on every platform.
  • Integrates Expose a project resource child PID or evaluated AssemblyName for debugger attach #18937's launcher-child behavior: dotnet run requires the direct application child, while dotnet watch and go run support verified descendants.
  • Preserves the selected AppHost PID through fresh resolution, serialization, CLI capability checks, and session tracking so concurrent runs from the same AppHost path are not conflated.
  • Detects resource processes already owned by an Aspire-launched VS Code debug session and returns alreadyDebugging.
  • Publishes non-sensitive project.launchCommand, project.configuration, and project.targetFramework snapshot metadata. Current snapshots use exact TargetPath identity; the TargetName compatibility fallback is limited to older snapshots that do not contain the new metadata.
  • Adds classified resource-debug telemetry without resource names, paths, PIDs, arguments, environment values, or raw failures.
  • Adds tree enablement, progress, cancellation, debugger-extension guidance, and localized outcomes.
  • Adds aspire_resource_debug with input validation, explicit confirmation, invocation-time re-resolution, linked cancellation, and bounded output.
  • Adds packaged VSIX E2E coverage for package contributions, resource-debug tool behavior, privacy boundaries, edge cases, and real .NET and Go attach sessions.

Evidence

Real process-tree validation covers:

  • dotnet run: the application is a direct child.
  • dotnet watch: the application is a transitive descendant.
  • go run: the application is a descendant.
  • Exact .NET target selection with same-name decoys and non-default assembly names.
  • Kernel-backed macOS executable lookup for long names.
  • Go/Delve attach without trusting flattened command text.

The packaged Linux VSIX E2E shard installs pinned C# and Go debugger extensions plus Delve. It invokes the registered resource-debug tool for both languages, binds a source breakpoint, observes the matching stack frame, detaches, verifies the resource still responds, and tears down the AppHost.

Validation

extension compile, lint, and unit tests
  2943 passing
  5 pending

focused debugger unit tests
  866 passing

Aspire.Cli.Tests
  146 total
  141 passed
  5 skipped (platform-specific)

ResourceSnapshotBuilderTests
  25 passed

ExtensionE2eWorkflowTests + TestTriggerMapTests
  38 passed

extension production package
  succeeded

resource-debug-tools packaged VSIX E2E
  passed on Linux and Windows CI

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

The language-model boundary intentionally excludes process IDs, absolute paths, arguments, environment values, and raw failures. Debug attachment also requires VS Code confirmation before invocation.

Copilot AI balanced review requested due to automatic review settings July 1, 2026 20:16
@github-actions

github-actions Bot commented Jul 1, 2026

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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18602

Or

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

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

This PR adds the first VS Code extension lane for #18538: a right-click Attach debugger action on running .NET project resources in the Aspire panel. It builds a CoreCLR attach debug configuration that targets the project's process by processName (best-effort resolving <AssemblyName> from the project file), rather than executable.pid, because DCP reports the dotnet run launcher PID rather than the child app process. The action is gated on a running top-level Project resource with a dotnet executable and a .csproj/.fsproj/.vbproj path, and only when the C# extension is installed; it re-resolves the latest resource before attaching so stale/ambiguous/missing resources fail closed with a warning.

Bundled alongside the feature is a broad telemetry overhaul: every event is renamed to its final wire name (aspire/vscode/... and aspire/dashboard/...) and routed through sendDangerousTelemetryEvent/sendDangerousTelemetryErrorEvent to bypass VS Code's automatic <extensionId>/ prefix, with manual opt-in gating (telemetryLevel), manual common properties, and explicit value sanitization.

Changes:

  • Add aspire-vscode.attachDebuggerToResource command, menu contribution (canAttachDebugger context value), attachability helpers, and the attach execution flow with latest-resource re-resolution.
  • Rename all telemetry events to final wire names and route them through the "dangerous" send path with explicit gating/sanitization and manually-added common properties.
  • Add localized strings and extensive unit tests for both the attach flow and the telemetry changes.
Show a summary per file
File Description
extension/src/views/AspireAppHostTreeProvider.ts Core attach logic: attachability helpers, process-name derivation, attachDebuggerToResource, latest-resource resolution; propagates appHostPath through tree items.
extension/src/extension.ts Registers the new attach command; renames the extension/activated telemetry event.
extension/package.json Contributes the command, hidden palette entry, and view/item/context menu item; reorders action groups.
extension/package.nls.json / extension/src/loc/strings.ts / extension/loc/xlf/aspire-vscode.xlf Adds/regenerates localized strings for the attach action.
extension/src/utils/telemetry.ts Switches to dangerous-send path, adds manual gating, common properties, and value sanitization; hard-codes telemetry client version.
extension/src/utils/telemetryRegistry.ts Renames event schema keys to final aspire/vscode/... and aspire/dashboard/... wire names; documents the convention.
extension/telemetry.json Updates classification inventory keys to the new wire names.
extension/src/dcp/DashboardTelemetryPassthrough.ts / AspireDcpServer.ts / AspireDebugSession.ts / AppHostLaunchService.ts / AppHostsViewTelemetry.ts / meaningfulEngagement.ts / appHostDiscovery.ts / workspace.ts / interactionService.ts Update event-name call sites and passthrough comments to the new namespaces.
extension/src/test/*.test.ts, extension/src/test-e2e/packageSurface.e2e.test.ts Extensive tests for the attach flow, telemetry gating/sanitization/naming, and the manifest/surface contributions.

Review details

  • Files reviewed: 29/29 changed files
  • Comments generated: 3
  • Review effort level: Medium

Comment thread extension/src/utils/telemetry.ts Resolved
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI review requested due to automatic review settings July 1, 2026 23:36

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: 30/30 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread extension/src/utils/telemetry.ts Resolved
Copilot AI review requested due to automatic review settings July 1, 2026 23:45

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: 30/30 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread extension/src/dcp/AspireDcpServer.ts Resolved
@adamint

Adam Ratzman (adamint) commented Jul 2, 2026 •

Copy link
Copy Markdown
Member Author

I tried to place these as inline tracking comments, but GitHub rejected new inline comments because there is already a pending review draft for this user on the PR. I kept the tracking here instead while the branch was fixed:

  1. The handled attach guard failures in attachDebuggerToResource should return a failure result for command telemetry instead of plain void, otherwise withCommandTelemetry records user-visible attach failures as successful invocations.
  2. The home-directory sanitizer needed coverage and a fix for usernames with spaces; paths like /Users/Alice Smith/project or C:\Users\Alice Smith\project could leave part of the username in telemetry after the dangerous-send path.

These were fixed before the later Windows punctuation redaction follow-up. This is a top-level tracking comment, so there is no review thread to resolve; final tracking is in #18602 (comment).

@adamint

Adam Ratzman (adamint) commented Jul 2, 2026 •

Copy link
Copy Markdown
Member Author

Pushed 8f4fe85 with the Windows telemetry redaction fix. Windows CI caught that the home-directory sanitizer could cross punctuation/text between two C:\Users\... paths; the parser now keeps punctuation boundaries intact and the regression is covered.

Validation on the live head passed locally: compile-tests, lint, compile, and full telemetry.test (31 passing). gh pr checks is green on 8f4fe85 (328 success / 0 pending / 3 skipped / 0 failed), and the review/test fleet found no blocking agent-owned follow-up.

Remaining non-agent gates: live CoreCLR attach/manual readiness pass, plus telemetry/reviewer sign-off for the common.* properties and dangerous-send sanitizer parity.

Copilot AI review requested due to automatic review settings July 2, 2026 20:14

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: 30/30 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

Copilot AI review requested due to automatic review settings July 3, 2026 02:09

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: 30/30 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

Copilot AI review requested due to automatic review settings July 3, 2026 02:46

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: 30/30 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

Copilot AI review requested due to automatic review settings July 4, 2026 15:42

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: 30/30 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

Copilot AI review requested due to automatic review settings July 4, 2026 16:36

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: 30/30 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

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.

🔵 Needs a closer look

Cross-platform process selection, debugger ownership, and confirmation/privacy boundaries require final human review despite the reported passing validation.

No open issues 🎉

Review effort: Balanced

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.

Approved from my side.

Thanks for the helpful feedback, Sébastien Ros (@sebastienros)! I'd appreciate you taking another look at the DCP/Go launch fixes before we merge.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

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

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.

🟡 Changes recommended

The accept task is not coordinated with teardown, allowing concurrent changes to _disposables that can cause collection-modified exceptions or leave objects undisposed.

1 open issue

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@IEvangelist

Copy link
Copy Markdown
Member

PR Testing Report

PR Information

Artifact Version Verification

  • Expected Commit: 7a3f25f
  • Installed Version: 17.0.0-pr.18602.g7a3f25fb
  • Status: ✅ Verified — the installed version includes the PR head short SHA.

Changes Analyzed

The PR changes 104 files. The tested surfaces include:

  • extension/src/debugger/resourceDebugService.ts, languages/dotnet.ts, languages/go.ts, and launchedChildProcessDiscovery.ts — resource resolution and debugger attachment.
  • extension/src/lm/resourceDebugToolService.ts and related contracts/adapters — confirmed, bounded language-model tool behavior.
  • extension/src/test-e2e/resourceDebugTools.e2e.test.ts and debugger unit tests — positive and negative coverage.
  • src/Aspire.Hosting.Go/GoRunDebugging.cs and src/Aspire.Hosting/Dcp/ResourceSnapshotBuilder.cs — Go launch flags and snapshot metadata.
  • src/Aspire.Cli/Backchannel/AppHostConnectionResolver.cs and src/Aspire.Cli/Commands/DescribeCommand.cs — CLI resolution and metadata output.
  • .github/workflows/extension-e2e-tests.yml and eng/github-ci/test-trigger-map.yml — platform E2E shards and Go test routing.

Change Categories

  • CLI changes
  • Hosting changes
  • Dashboard changes
  • Template changes
  • Client/component changes
  • VS Code extension changes
  • Test and CI workflow changes

Test Scenarios Executed

Scenario 1: PR CLI artifact version

Objective: Verify the downloaded CLI artifact belongs to this PR head.
Coverage Type: Artifact verification
Status: ✅ Passed

Steps: Installed PR #18602's CLI and package hive in the repo container, then invoked the installed binary directly with --version.

Evidence: dogfood-install.log; CLI output 17.0.0-pr.18602.g7a3f25fb.

Scenario 2: Go launch-debugging and resource snapshot tests

Objective: Validate the Go-specific launch configuration and snapshot metadata.
Coverage Type: Targeted unit tests
Status: ✅ Passed

Steps and results:

  • GoRunDebuggingTests: 23 passed, 0 failed.
  • ResourceSnapshotBuilderTests: 47 passed, 0 failed.

Evidence: targeted-tests.log.

Scenario 3: CLI AppHost resolution and describe tests

Objective: Validate AppHost connection resolution and emitted debug metadata.
Coverage Type: Targeted unit tests
Status: ⚠️ Partial local result; PR CI passed.

Steps and results:

  • AppHostConnectionResolverTests: 15 passed; 1 macOS-specific test skipped as expected.
  • DescribeCommandTests: 49 passed, 1 local failure. The failing snapshot test compared CRLF expected text with LF output because this Windows checkout was mounted into the Linux container. The matching PR CLI test jobs passed on Ubuntu, Windows, and macOS.

Evidence: cli-resolver-tests.log, cli-describe-tests.log; PR CI jobs Ubuntu, Windows, and macOS.

Scenario 4: Packaged VSIX debugger attachment and safe failures

Objective: Exercise real .NET and Go debugger attachment, breakpoint handling, detach, continued resource responsiveness, and the negative resource-debug path.
Coverage Type: Packaged VS Code Extension Host E2E
Status: ✅ Passed in PR CI; not repeated locally.

The repo container did not include Node/Corepack or Go, so the packaged VSIX E2E could not be run locally without installing an additional toolchain. The PR's own E2E workflow ran the Linux positive shard and Windows positive and negative shards successfully:

Scenario 5: Test-routing and workflow coverage

Objective: Validate the Go test-selection map and extension E2E workflow wiring.
Coverage Type: Infrastructure tests and PR workflow execution
Status: ✅ PR CI passed; local run had one container-metadata limitation.

The matching PR CI jobs passed: Infrastructure.Tests and extension unit tests. The local filtered Infrastructure.Tests run had 150 passes and one environment-only failure: ExtensionJavaE2eDiscoveryInputsAreNotGitIgnored could not run git check-ignore because the Windows worktree's .git pointer resolved to an inaccessible Windows path inside Linux. The workflow is a workflow_call consumer and ran through the PR's CI; no manual upstream dispatch was needed.

Evidence: ci-routing-tests.log.

CI Infrastructure Validation

GitHub Actions:

  • The PR's Linux and Windows resource-debug E2E shards and negative Windows shard all completed successfully.
  • The extension unit, Go hosting, CLI, and Infrastructure.Tests jobs passed in the latest PR run. Earlier failures in Dashboard.Components and Hosting.JavaScript were green on the latest run; these areas are outside the PR diff.
  • git diff --check upstream/main...upstream/pr/18602 passed.
  • The E2E workflow is reusable via workflow_call; the PR CI exercised it through its caller. No manual dispatch or upstream push was performed.
  • The changed workflow reuses existing pinned actions; no action SHA changes were introduced.
  • Artifact upload names and downstream workflow contracts were not changed.

Azure DevOps: n/a — no Azure Pipelines files changed.

Summary

Scenario Status Notes
PR CLI artifact version ✅ Passed Exact PR head short SHA in version
Go launch-debugging / snapshot tests ✅ Passed 23 + 47 tests passed
CLI resolution / describe ⚠️ Partial locally Resolver tests passed; describe snapshot differed only in line endings; PR CI passed across OSes
Packaged VSIX debugger E2E ✅ Passed Linux, Windows, and negative Windows jobs passed in PR CI
Workflow and test routing ✅ Passed in PR CI Local run: 150 passed, 1 blocked by Windows .git pointer in Linux container

Overall Result

✅ PR VERIFIED — relevant PR CI checks passed, including packaged Linux/Windows debugger E2E and the negative shard. Local container limitations are documented above.

Recommendations

  • No PR-specific test failure remains in the latest PR checks.

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

Copy link
Copy Markdown
Member

Ella Hathaway (@ellahathaway) have you pulled this and tested out locally the Go debugging experience?

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.

🟡 Changes recommended

The Linux debugging instructions omit the ptrace restriction that can prevent Delve from attaching and need to document an administrator-approved configuration or recommend Start Debugging instead.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread src/Aspire.Hosting.Go/README.md Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@ellahathaway

Copy link
Copy Markdown
Contributor

Ella Hathaway (Ella Hathaway (@ellahathaway)) have you pulled this and tested out locally the Go debugging experience?

I have, here's a demo:

go_debugging_demo.mp4

@IEvangelist

Copy link
Copy Markdown
Member

Ella Hathaway (Ella Hathaway (Ella Hathaway (@ellahathaway))) have you pulled this and tested out locally the Go debugging experience?

I have, here's a demo:

go_debugging_demo.mp4

:shipit:

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose a project resource child PID or evaluated AssemblyName for debugger attach [VS Code] Attach a debugger to resources in a running AppHost

6 participants