Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15664Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15664" |
There was a problem hiding this comment.
Pull request overview
Adds ATS-friendly support for surfacing HTTP command response bodies as command results, enabling exported metadata + generated polyglot projections to describe response handling (JSON/text/auto/none).
Changes:
- Introduces
HttpCommandResultModeandHttpCommandOptions.ResultMode, plus default logic to capture/format HTTP response bodies when opted in. - Adds an ATS-specific
withHttpCommandexport with an ATS-friendly DTO (HttpCommandExportOptions) and updates ATS scanning/codegen to respect[AspireDto(Name=...)]. - Updates stress playground endpoints and refreshes TypeScript/Go/Java/Python/Rust generation snapshots and tests.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/WithHttpCommandTests.cs | Adds unit tests for result-mode behavior and content-type inference. |
| tests/Aspire.Hosting.RemoteHost.Tests/AtsCapabilityScannerTests.cs | Validates withHttpCommand capability export shape + DTO surface. |
| src/Aspire.Hosting/ApplicationModel/HttpCommandOptions.cs | Adds HttpCommandResultMode, ResultMode, and the ATS DTO for export options. |
| src/Aspire.Hosting/ResourceBuilderExtensions.cs | Implements default result capture logic and adds ATS export withHttpCommand. |
| src/Aspire.Hosting/Ats/AspireDtoAttribute.cs | Adds Name to control exported DTO naming. |
| src/Aspire.TypeSystem/AttributeDataReader.cs | Adds parsing support for [AspireDto] data (including Name). |
| src/Aspire.Hosting.RemoteHost/AtsCapabilityScanner.cs | Uses parsed DTO name when producing ATS DTO type info. |
| src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs | Uses scanned DTO names for TS interfaces + supports “direct options DTO” parameters. |
| src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs | Uses scanned DTO names for Python DTOs. |
| playground/Stress/Stress.AppHost/Program.cs | Adds sample HTTP commands demonstrating result modes. |
| playground/Stress/Stress.ApiService/Program.cs | Adds endpoints returning JSON/text to exercise the new result modes. |
| tests/**/Snapshots/.verified. | Updates polyglot SDK/codegen snapshots to include the new capability, DTO, and enum. |
Comments suppressed due to low confidence (1)
src/Aspire.Hosting/ResourceBuilderExtensions.cs:2431
- XML doc has a typo: "succesful" should be "successful".
/// is not specified, the command will be considered succesful if the response status code is in the 2xx range. Set
| var dtoAttr = AttributeDataReader.GetAspireDtoData(type); | ||
| var typeId = AtsTypeMapping.DeriveTypeId(type); | ||
| var typeName = type.Name; | ||
| var typeName = dtoAttr?.Name ?? type.Name; |
There was a problem hiding this comment.
AspireDtoAttribute.Name is described as optional; if it’s set to an empty/whitespace string, this will currently override type.Name and can lead to empty/invalid DTO type names in generated SDKs. Consider treating null/empty/whitespace as "not specified" (or validating and throwing) before using it for typeName.
| var typeName = dtoAttr?.Name ?? type.Name; | |
| var typeName = dtoAttr?.Name is string name && !string.IsNullOrWhiteSpace(name) | |
| ? name | |
| : type.Name; |
| /// <para> | ||
| /// The <see cref="HttpCommandOptions.GetCommandResult"/> callback will be invoked after the response is received to determine the result of the command invocation. If this callback | ||
| /// is not specified, the command will be considered succesful if the response status code is in the 2xx range. | ||
| /// is not specified, the command will be considered succesful if the response status code is in the 2xx range. Set |
There was a problem hiding this comment.
XML doc has a typo: "succesful" should be "successful".
This issue also appears on line 2431 of the same file.
| /// is not specified, the command will be considered succesful if the response status code is in the 2xx range. Set | |
| /// is not specified, the command will be considered successful if the response status code is in the 2xx range. Set |
| return response.IsSuccessStatusCode | ||
| ? CommandResults.Success() | ||
| : CommandResults.Failure($"Request failed with status code {response.StatusCode}"); | ||
| return await GetDefaultHttpCommandResultAsync(response, commandOptions, context.CancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
The HTTP response is used to compute the command result but is never disposed. To avoid holding open the underlying connection/content stream, consider disposing the HttpResponseMessage in a finally after either GetCommandResult completes or the default result logic runs.
| } | ||
|
|
||
| /// <summary> | ||
| /// Optional configuration for resource HTTP commands added with <see cref="ResourceBuilderExtensions.WithHttpCommand{TResource}(Aspire.Hosting.ApplicationModel.IResourceBuilder{TResource}, string, string, string?, string?, Aspire.Hosting.ApplicationModel.HttpCommandOptions?)"/>."/> |
There was a problem hiding this comment.
The XML documentation appears malformed due to an extra "/> at the end of the <see .../> tag, which can trigger CS1570/CS1574 warnings (and potentially fail the build if treated as errors). Please fix the <see cref="..."/> usage so the summary is well-formed XML.
| /// Optional configuration for resource HTTP commands added with <see cref="ResourceBuilderExtensions.WithHttpCommand{TResource}(Aspire.Hosting.ApplicationModel.IResourceBuilder{TResource}, string, string, string?, string?, Aspire.Hosting.ApplicationModel.HttpCommandOptions?)"/>."/> | |
| /// Optional configuration for resource HTTP commands added with <see cref="ResourceBuilderExtensions.WithHttpCommand{TResource}(Aspire.Hosting.ApplicationModel.IResourceBuilder{TResource}, string, string, string?, string?, Aspire.Hosting.ApplicationModel.HttpCommandOptions?)"/>. |
3622e08 to
81db386
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
81db386 to
abf2a0b
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23678701893 |
Description
Adds HTTP command result support so AppHost commands can describe how HTTP responses should be surfaced in exported metadata and generated language projections.
This change:
HttpCommandResultModeandHttpCommandOptionswithHttpCommandoptionsparameterDuring review, the temporary ATS DTO rename support was removed. DTO names now continue to come from the CLR type name, and the HTTP command export shape uses a dedicated
HttpCommandExportOptionstype instead of attribute-based renaming.Fixes #8729
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: