Skip to content

Reapply parser-backed AppHost resource parsing#17480

Open
davidfowl wants to merge 2 commits into
mainfrom
davidfowl/unrevert-pr
Open

Reapply parser-backed AppHost resource parsing#17480
davidfowl wants to merge 2 commits into
mainfrom
davidfowl/unrevert-pr

Conversation

@davidfowl
Copy link
Copy Markdown
Contributor

Description

This reapplies parser-backed AppHost resource parsing from #17361 so the VS Code extension no longer treats commented-out resource declarations or sample code inside strings as active AppHost resources. That restores the CodeLens and gutter behavior from the original PR while keeping the Yarn-only restore fixes now on main.

The C# parser uses Tree-sitter again, JavaScript and TypeScript parsing use syntax-tree traversal, and the AppHost file presence, CodeLens, gutter decoration, and parser tests are restored for active resources, comments, block comments, trailing comments, string literals, and file-based C# AppHosts. The extension remains Yarn-only: package-lock.json stays deleted, .npmrc only configures the internal npm feed for Yarn v1, and the new tree-sitter lockfile entries resolve through dotnet-public-npm instead of public npm registry URLs.

Validation:

  • cd extension && yarn install --frozen-lockfile --non-interactive && yarn test
  • ./restore.sh && MSBUILDTERMINALLOGGER=false dotnet build extension/Extension.proj /t:ValidateYarnLockRegistries /v:minimal

Fixes # (issue)

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
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

This reverts the revert of #17361 and keeps the Yarn-only extension restore behavior from main. The tree-sitter dependencies resolve through the internal npm feed and package-lock.json remains deleted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 26, 2026 00:36
@davidfowl davidfowl requested a review from adamint as a code owner May 26, 2026 00:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

🚀 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 -- 17480

Or

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

Keep the parser dependency lockfile update limited to the tree-sitter entries needed by the unrevert while preserving internal npm feed URLs.

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

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reapplies parser-backed AppHost resource parsing in the VS Code extension so commented-out Add*/add* calls and resource-like strings no longer produce active CodeLens/gutter UI, while keeping the Yarn-only restore workflow.

Changes:

  • Reintroduced syntax-based parsing: C# AppHost parsing via web-tree-sitter + tree-sitter-c-sharp (WASM), JS/TS AppHost parsing via TypeScript AST traversal.
  • Updated CodeLens, gutter decorations, and AppHost file presence detection to use async parser APIs and added/updated tests for comment/string filtering and stale-update handling.
  • Updated webpack config and extension dependencies/lockfile to bundle/load .wasm assets needed by Tree-sitter, and adjusted VS Code launch/tasks to run yarn install before watch/launch.
Show a summary per file
File Description
extension/yarn.lock Updates lockfile for Tree-sitter-related dependencies and other resolution reshaping under Yarn.
extension/webpack.config.js Adds webpack handling to emit .wasm files as resources for runtime loading.
extension/src/types/web-tree-sitter.d.ts Adds type augmentation needed to pass locateFile to Tree-sitter init in TS.
extension/src/test/vscodeWorkspaceConfig.test.ts Adds tests ensuring launch/tasks run yarn install before launching the extension.
extension/src/test/parsers.test.ts Updates parser tests for async APIs and validates comment/string filtering behavior.
extension/src/test/aspireCodeLensProvider.test.ts Expands CodeLens + gutter decoration tests, including stale-result suppression scenarios.
extension/src/test/appHostFilePresenceWatcher.test.ts Updates presence watcher tests for async behavior and debounced updates.
extension/src/editor/parsers/parserUtils.ts Removes regex-based statement/comment utilities superseded by parser-backed implementations.
extension/src/editor/parsers/jsTsAppHostParser.ts Replaces regex scanning with TypeScript AST traversal for JS/TS AppHost detection and resource parsing.
extension/src/editor/parsers/csharpAppHostParser.ts Reintroduces Tree-sitter-backed C# parsing with WASM loading and AST-based filtering of inactive code.
extension/src/editor/parsers/AppHostResourceParser.ts Makes parser contract async and updates registry lookup to await isAppHostFile.
extension/src/editor/AspireGutterDecorationProvider.ts Switches gutter decoration computation to async parsing and adds per-editor versioning to ignore stale results.
extension/src/editor/AspireCodeLensProvider.ts Updates CodeLens provider to async parsing and adds cancellation handling.
extension/src/editor/AppHostFilePresenceWatcher.ts Converts AppHost visibility detection to async parsing with coalesced queued updates.
extension/package.json Adds tree-sitter-c-sharp and web-tree-sitter dependencies required for C# parsing.
extension/.vscode/tasks.json Adds a Yarn install task and a compound watch task for extension workspace.
extension/.vscode/launch.json Updates preLaunchTask to the new compound watch task.
.vscode/tasks.json Adds a Yarn install task and compound watch task for repo workspace.
.vscode/launch.json Updates preLaunchTask to the new compound watch task for repo workspace launches.

Copilot's findings

  • Files reviewed: 17/19 changed files
  • Comments generated: 3

const value = this._anyVisibleEditorIsAppHost();
private _queueUpdate(): void {
const version = ++this._updateVersion;
this._updateTask = this._update(version);
Comment on lines +61 to 72
private async _update(version: number): Promise<void> {
const value = await this._anyVisibleEditorIsAppHost();
if (version !== this._updateVersion) {
return;
}

if (value === this._lastValue) {
return;
}
this._lastValue = value;
this._repository.setAppHostFileOpen(value);
}
Comment on lines 131 to 144
this._debounceTimer = setTimeout(() => {
this._debounceTimer = undefined;
for (const editor of vscode.window.visibleTextEditors) {
if (editor.document === document) {
this._applyDecorations(editor);
void this._applyDecorations(editor);
}
}
}, 250);
}

private _updateAllVisibleEditors(): void {
for (const editor of vscode.window.visibleTextEditors) {
this._applyDecorations(editor);
void this._applyDecorations(editor);
}
@github-actions
Copy link
Copy Markdown
Contributor

CLI E2E Tests unknown — 95 passed, 0 failed, 6 unknown (commit f06b91f)

View all recordings
Status Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View recording
AddPackageWhileAppHostRunningDetached ▶️ View recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View recording
AgentInitCommand_DefaultSelection_InstallsDefaultSkills ▶️ View recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View recording
AgentMcpListStructuredLogsFromStarterAppCore ▶️ View recording
AllPublishMethodsBuildDockerImages ▶️ View recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View recording
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ▶️ View recording
AspireInitWithExistingAppHostDirRecreatesMissingNuGetConfigAndPreservesFiles ▶️ View recording
AspireInitWithSolutionFileGeneratesAppHostThatBuildsAgainstChannelHive ▶️ View recording
AspireStartUpdatesStaleTypeScriptAppHostPath ▶️ View recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View recording
AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrent ▶️ View recording
Banner_DisplayedOnFirstRun ▶️ View recording
Banner_DisplayedWithExplicitFlag ▶️ View recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View recording
CertificatesClean_RemovesCertificates ▶️ View recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View recording
CreateAndRunAspireStarterProject ▶️ View recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View recording
CreateAndRunEmptyAppHostProject ▶️ View recording
CreateAndRunJavaEmptyAppHostProject ▶️ View recording
CreateAndRunJsReactProject ▶️ View recording
CreateAndRunPythonReactProject ▶️ View recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View recording
CreateAndRunTypeScriptStarterProject ▶️ View recording
CreateJavaAppHostWithViteApp ▶️ View recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View recording
DashboardRunWithAgentMcpCore ▶️ View recording
DashboardRunWithOtelTracesReturnsNoTracesCore ▶️ View recording
DeployK8sBasicApiService ▶️ View recording
DeployK8sWithExternalHelmChart ▶️ View recording
DeployK8sWithGarnet ▶️ View recording
DeployK8sWithMongoDB ▶️ View recording
DeployK8sWithMySql ▶️ View recording
DeployK8sWithPostgres ▶️ View recording
DeployK8sWithRabbitMQ ▶️ View recording
DeployK8sWithRedis ▶️ View recording
DeployK8sWithSqlServer ▶️ View recording
DeployK8sWithValkey ▶️ View recording
DeployTypeScriptAppToKubernetes ▶️ View recording
DescribeCommandResolvesReplicaNames ▶️ View recording
DescribeCommandShowsRunningResources ▶️ View recording
DetachFormatJsonProducesValidJson ▶️ View recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View recording
DoListStepsShowsPipelineSteps ▶️ View recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View recording
GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchain ▶️ View recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View recording
GlobalMigration_PreservesAllValueTypes ▶️ View recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View recording
JavaScriptHostingApisRunFromTypeScriptAppHost ▶️ View recording
LatestCliCanStartStableChannelAppHost ▶️ View recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View recording
LogLevelTrace_ProducesTraceEntriesInCliLogFile ▶️ View recording
LogsCommandShowsResourceLogs ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterAppIsolated ▶️ View recording
PsCommandListsRunningAppHost ▶️ View recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View recording
PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifacts ▶️ View recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View recording
ResourceCommand_FailedExecution_DisplaysAppHostLogPathAndLogContainsEntries ▶️ View recording
ResourceCommand_FailsWhenInteractionServiceIsRequired ▶️ View recording
ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutput ▶️ View recording
RestoreGeneratesSdkFiles ▶️ View recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View recording
RunPublishFailureScenarioAsync ▶️ View recording
RunReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
RunReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
SecretCrudOnDotNetAppHost ▶️ View recording
SecretCrudOnTypeScriptAppHost ▶️ View recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View recording
StartReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
StartReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
StopAllAppHostsFromAppHostDirectory ▶️ View recording
StopJavaPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopNonInteractiveSingleAppHost ▶️ View recording
StopTypeScriptPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View recording
UpdateProjectChannelToStable_TypeScript_PicksUpStablePackages ▶️ View recording

📹 Recordings uploaded automatically from CI run #26425776700

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