Skip to content

Conversation

@eerhardt
Copy link
Member

Description

This reverts aab8668.

Re-enabling Initial extension interaction service (#9927) with supporting native AOT.

Reuse the same Json source generation context. Add ExtensionBackchannel types to it.

Need to suppress a RDC warning due to EventHandlers on the Rpc Target object needing to call MakeGenericMethod, but we aren't using EventHandlers so it can be suppressed.

Fixes # 10029

eerhardt added 2 commits June 25, 2025 10:55
Reuse the same Json source generation context. Add ExtensionBackchannel types to it.

Need to suppress a RDC warning due to EventHandlers on the Rpc Target object needing to call MakeGenericMethod, but we aren't using EventHandlers so it can be suppressed.
Copy link
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

This PR re-enables the extension interaction service with native AOT support, reuses existing JSON source-gen context, and wires through an OpenNewProject flow tied to template creation.

  • Introduces extension-related configuration keys and backchannel RPC types
  • Updates ITemplate.ApplyTemplateAsync to return a TemplateResult carrying exit code and output path
  • Refactors Program.cs to register either console or extension-based interaction services

Reviewed Changes

Copilot reviewed 56 out of 93 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Aspire.Cli.Tests/TestServices/TestConsoleInteractionService.cs Added OpenNewProject stub to satisfy new interface method
src/Shared/KnownConfigNames.cs Added constants for extension endpoint, prompt flag, token, and cert
src/Aspire.Cli/Utils/StringUtils.cs Introduced RemoveSpectreFormatting extension method with regex
src/Aspire.Cli/Templating/ITemplate.cs Changed return type of ApplyTemplateAsync to TemplateResult
src/Aspire.Cli/Templating/DotNetTemplateFactory.cs Adjusted helper methods to return TemplateResult
src/Aspire.Cli/Templating/CallbackTemplate.cs Adapted callback signature to use TemplateResult
src/Aspire.Cli/Program.cs Refactored to async build, added AddInteractionServices helper
src/Aspire.Cli/Interaction/IInteractionService.cs Added OpenNewProject method
src/Aspire.Cli/Interaction/ExtensionInteractionService.cs Implemented extension backchannel queuing and prompt forwarding
src/Aspire.Cli/Interaction/ConsoleInteractionService.cs Added empty OpenNewProject implementation
src/Aspire.Cli/Commands/RunCommand.cs Expanded OperationCanceledException catch to include None tokens
src/Aspire.Cli/Commands/NewCommand.cs Switched to using TemplateResult, calls OpenNewProject if set
src/Aspire.Cli/Backchannel/ExtensionRpcTarget.cs New RPC target for version and prompt validation
src/Aspire.Cli/Backchannel/ExtensionBackchannel.cs Full client implementation for extension RPC backchannel
src/Aspire.Cli/Backchannel/BackchannelJsonSerializerContext.cs Added source-generated JSON formatter context
src/Aspire.Cli/Backchannel/BackchannelDataTypes.cs Added DisplayLineState type for backchannel payloads
src/Aspire.Cli/Backchannel/AppHostIncompatibleException.cs Made exception non-sealed to unify with extension patterns
src/Aspire.Cli/Backchannel/AppHostBackchannel.cs Switched to JSON source-generated formatter (removed manual method)
extension/src/utils/vsc.ts Updated isWorkspaceOpen to optionally suppress error popup
extension/src/utils/terminal.ts Inject extension env vars (token, cert) into new terminal
extension/src/test/rpc/e2eServerTests.test.ts Changed RPC e2e tests to use TLS client for certificate-based auth
extension/src/server/rpcServer.ts Converted RPC server to use TLS, error handling, included cert field
extension/src/server/interactionService.ts Added openProject RPC endpoint
extension/src/server/cert-util.ts New helper to generate self-signed certs
extension/src/constants/strings.ts Added rpcServerError localized string
extension/src/commands/new.ts Removed pre-check to allow extension to open folder
extension/package.json Added node-forge and corresponding types dependency
extension/package.nls.* (all locales) Updated localization JSONs to include rpcServerError entries
Files not reviewed (1)
  • src/Aspire.Cli/Resources/ErrorStrings.Designer.cs: Language not supported
Comments suppressed due to low confidence (1)

src/Aspire.Cli/Commands/NewCommand.cs:96

  • This new OpenNewProject call isn’t currently covered by existing tests. Consider adding a unit test to verify that calling new with an output path invokes OpenNewProject on the interaction service.
            _interactionService.OpenNewProject(templateResult.OutputPath);

}
}
catch (OperationCanceledException ex) when (ex.CancellationToken == cancellationToken)
catch (OperationCanceledException ex) when (ex.CancellationToken == cancellationToken || ex.CancellationToken == CancellationToken.None)
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

The added condition ex.CancellationToken == CancellationToken.None may inadvertently swallow unrelated cancellations. Consider limiting the catch to the passed-in token only.

Suggested change
catch (OperationCanceledException ex) when (ex.CancellationToken == cancellationToken || ex.CancellationToken == CancellationToken.None)
catch (OperationCanceledException ex) when (ex.CancellationToken == cancellationToken)

Copilot uses AI. Check for mistakes.
eerhardt added 2 commits June 25, 2025 14:08
Remove Exception from the wire payload since it can't be safely STJ serialized using the source generator.

Enable Configuration Binder source generator in the Aspire.Cli.
@adamint
Copy link
Member

adamint commented Jun 25, 2025

needs .localization/out and dist files removed from tracking before merge

@adamint adamint merged commit 5629f99 into dotnet:main Jun 25, 2025
252 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants