feat: Expose ReferenceExpression get value and enhance server value resolution#15138
feat: Expose ReferenceExpression get value and enhance server value resolution#15138IEvangelist merged 5 commits intorelease/13.2from
ReferenceExpression get value and enhance server value resolution#15138Conversation
…alue resolution - Updated ReferenceExpression to support conditional expressions with fields for condition, matchValue, whenTrue, and whenFalse. - Introduced static method createConditional for creating conditional ReferenceExpressions. - Implemented getValue method to resolve the expression's value on the server, including cancellation support. - Registered handle wrapper for ReferenceExpression in base.ts to avoid duplication in generated SDK. - Added AppHostUsageError for better error handling in capability argument validation. - Improved async method handling in CapabilityDispatcher to support ValueTask. - Added tests for ReferenceExpression and ValueTask methods to ensure correct functionality and exports.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15138Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15138" |
ReferenceExpression get value and enhance server value resolution
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22985137955 |
There was a problem hiding this comment.
Pull request overview
This PR improves the Aspire polyglot/ATS experience by enabling server-side resolution of ReferenceExpression values from the generated TypeScript SDK and by extending the RemoteHost capability dispatcher to correctly handle ValueTask-based capability methods.
Changes:
- Exported
ReferenceExpression.GetValueAsync(...)as an ATS capability and added a TypeScriptReferenceExpression.getValue(...)helper (with cancellation support) plus a centralized handle-wrapper registration inbase.ts. - Refactored
CapabilityDispatcherasync result handling to unwrapTask,ValueTask, andValueTask<T>, and added tests forValueTask<T>capabilities. - Updated the TypeScript code generator to avoid generating a duplicate
ReferenceExpressionwrapper when it’s implemented manually inbase.ts, and added tests to enforce this.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.RemoteHost.Tests/CapabilityDispatcherTests.cs | Adds coverage for invoking ValueTask<T> capabilities (static + instance). |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs | Adds tests ensuring ReferenceExpression wrapper stays in base.ts and getValueAsync is exported. |
| src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs | Exposes GetValueAsync via [AspireExport] for polyglot access. |
| src/Aspire.Hosting.RemoteHost/Ats/CapabilityDispatcher.cs | Centralizes async unwrapping and adds ValueTask/ValueTask<T> support. |
| src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts | Adds ReferenceExpression.getValue(...) and registers a handle wrapper in base.ts. |
| src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs | Skips generating a duplicate ReferenceExpression wrapper class in aspire.ts. |
| playground/TypeScriptAppHost/.modules/transport.ts | Adds argument validation (detecting Promise-like args) before capability invocation. |
| playground/TypeScriptAppHost/.modules/base.ts | Syncs the playground SDK base types with new getValue(...) and wrapper registration. |
| playground/TypeScriptAppHost/.modules/aspire.ts | Updates generated playground SDK exports/behavior (including AppHostUsageError handling). |
You can also share your feedback on Copilot code review. Take the survey.
sebastienros
left a comment
There was a problem hiding this comment.
Probably change getValue first
|
The transient CI rerun workflow requested reruns for the following jobs after analyzing the failed attempt.
|
The ReferenceExpression class now exports a getValue capability via
[AspireExport("getValue")], so the generated Python SDK must include
the corresponding get_value method instead of a bare pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Expose
ReferenceExpressionget value and enhance server value resolutiongetValuemethod to resolve the expression's value on the server, including cancellation support.CapabilityDispatcherto supportValueTask/ValueTask<T>.ReferenceExpressioninbase.tsto avoid duplication in generated SDK.ReferenceExpressionandValueTaskmethods to ensure correct functionality and exports.Fixes #14772
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: