Skip to content

[docs] Document optional parameters and programmatic value setting - #1871

Merged
James Newton-King (JamesNK) merged 7 commits into
release/17.0from
docs/pr-18108-38196953664-1-bdd5be55301c964b
Nov 16, 2026
Merged

James Newton-King (JamesNK) merged 7 commits into
release/17.0from
docs/pr-18108-38196953664-1-bdd5be55301c964b

Conversation

@aspire-repo-bot

@aspire-repo-bot aspire-repo-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Documents changes from microsoft/aspire#18108 and the follow-up API rename in microsoft/aspire#22217

@davidfowl

Target branch

Targeting release/17.0 based on the source PR milestone 17.0.

Why this PR is needed

microsoft/aspire#18108 adds a first-class optional-parameter model and programmatic parameter value management to ParameterResource:

  • AsOptional() / AsRequired() extension methods (renamed from WithOptional() / WithRequired(bool) in [release/17.0] Address API review feedback from #22185 aspire#22217) let a parameter resolve to null instead of prompting or blocking publish when unset.
  • TryGetCurrentValue(out value) / TryGetCurrentValue() let AppHost code inspect the current value without waiting on an unresolved prompt.
  • SetValueAsync(value, cancellationToken) lets AppHost code set or clear a parameter's value programmatically, synchronizing dashboard state.
  • The manifest publisher doesn't support optional parameters and now throws a DistributedApplicationException instead of emitting schema-invalid output.
  • These APIs are exported through ATS, so the TypeScript (and other polyglot) AppHost SDKs expose equivalent asOptional, asRequired, setValueAsync, and tryGetCurrentValue members.

This is undocumented user-facing API surface (PR body "User-facing usage" section, pr_body_has_user_facing_section signal) spanning both the C# and TypeScript AppHost SDKs (polyglot_code_generator_changed signal), so the existing parameters documentation needed updating.

What changed

Added two new sections to src/frontend/src/content/docs/fundamentals/external-parameters.mdx, placed after "Secret values" and before "Add parameters from configuration":

  1. Optional parameters — explains AsOptional() / AsRequired(), the resulting null resolution behavior for dependent resources, and the manifest-publish restriction (drawn from reviewer discussion on the source PR about the manifest schema not supporting optional parameter inputs).
  2. Set and inspect parameter values programmatically — explains TryGetCurrentValue and SetValueAsync, including that SetValueAsync doesn't by itself persist to user secrets or deployment state (drawn from reviewer discussion clarifying that only ParameterProcessor.SetValueAsync with saveToUserSecrets: true persists).

Both sections include matching C# and TypeScript code samples, following the page's existing <Tabs syncKey="aspire-lang"> convention.

Files modified

  • src/frontend/src/content/docs/fundamentals/external-parameters.mdx (updated)
  • src/frontend/scripts/generate-twoslash-types.ts and src/frontend/src/data/twoslash/aspire.d.ts — adds asOptional, asRequired, tryGetCurrentValue, and setValueAsync to the post-snapshot ParameterResource shim so the TypeScript samples type-check until the ts-modules snapshot is refreshed

No new pages were created; this is an update to the existing parameters guide.

Generated by PR Documentation Check for #18108 · copilot · auto · 104.8 AIC · ⌖ 18.5 AIC · ⊞ 20.4K · ◷

Documents WithOptional/WithRequired and TryGetCurrentValue/SetValueAsync
on ParameterResource, added in microsoft/aspire#18108.

Co-authored-by: Copilot <[email protected]>
@aspire-repo-bot aspire-repo-bot Bot added the docs-from-code Copilot initiated issue from dotnet/aspire repo label Oct 12, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor Author

Frontend HTML artifact ready

The latest frontend build uploaded the frontend-dist artifact for PR #1871. Use the VS Code button below to open this PR with GitHub Artifacts Explorer and browse the built HTML locally.

VS Code: Open PR #1871 artifacts

This comment updates automatically when a new frontend build artifact is uploaded.

Copy link
Copy Markdown
Member

docs-pr-reviewer report — [partial — phase A: key claims evaluated; phase B: not run (docs site was not served in this automated run)]

Recommendation: approve

Source used: microsoft/aspire main via merged source PR microsoft/aspire#18108 (docs PR targets release/17.0; no matching branch checked).
PR status: draft, mergeable, opened 2026-10-12 (not stale)

Phase A — claims

  • ✅ verified: ParameterResource doc says unset optional parameters resolve to null from GetValueAsync.
  • ⚠️ nuance: the obsolete Value property returns an empty string for unset optional parameters (not null); the 'WithOptional() ≡ WithRequired(required: false)' equivalence and the TypeScript withOptional name were not traced in this run.

Phase B — doc-tester

Not run; rendering of the changed pages is not browser-checked.

🤖 Posted by aspire.dev - squad (AI Agent)

@IEvangelist
David Pine (IEvangelist) marked this pull request as ready for review November 13, 2026 14:57
Copilot AI balanced review requested due to automatic review settings November 13, 2026 14:57

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 documentation uses unavailable API methods, has stale TypeScript declarations and an incorrect publish command, and omits important value-handling behavior.

6 open issues
What changed in this PR

Updates the existing parameters guide for Aspire 17.0 to document optional parameters and programmatic value management introduced by microsoft/aspire#18108.

Changes:

  • Adds optional-parameter guidance with C# and TypeScript examples.
  • Shows how to inspect, set, and clear parameter values programmatically.
  • Adds notes on manifest publishing restrictions and value persistence.
File Description
src/​frontend/​src/​content/​docs/​fundamentals/​external-parameters.mdx Adds two sections covering optional parameters and programmatic value management.

Review effort: Balanced

microsoft/aspire#22217 replaced WithOptional/WithRequired(bool) with AsOptional/AsRequired. Update samples and prose, use aspire do publish-manifest, and add the new ParameterResource members to the twoslash type shims so TypeScript samples type-check.

Co-authored-by: Copilot <[email protected]>
@JamesNK
James Newton-King (JamesNK) force-pushed the docs/pr-18108-38196953664-1-bdd5be55301c964b branch from 2b627d8 to 1e32bc5 Compare November 16, 2026 06:22
Clarified behavior of SetValueAsync and its impact on deployment state.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@JamesNK
James Newton-King (JamesNK) merged commit f1276a2 into release/17.0 Nov 16, 2026
17 checks passed
@JamesNK
James Newton-King (JamesNK) deleted the docs/pr-18108-38196953664-1-bdd5be55301c964b branch November 16, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-from-code Copilot initiated issue from dotnet/aspire repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants