Address more C# bias#936
Open
alistairmatthews wants to merge 5 commits into
Open
Conversation
…able for TypeScript. Added an aside instead.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates several Aspire documentation articles to reduce C#-only bias by adding equivalent TypeScript AppHost examples and Go/Python/TypeScript consuming-app examples, aligning with issue #935.
Changes:
- Added
Tabs/TabItem-based language pivots for AppHost (C# + TypeScript) examples across multiple docs pages. - Added multi-language consuming-app examples (C#, Go, Python, TypeScript) where appropriate (e.g., service discovery, health checks, dashboard telemetry API keys).
- Added notes where specific APIs are not yet available in the TypeScript AppHost SDK.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/frontend/src/content/docs/fundamentals/service-discovery.mdx | Adds AppHost TS examples and multi-language consuming examples for named endpoints and DNS SRV scenarios. |
| src/frontend/src/content/docs/fundamentals/persist-data-volumes.mdx | Adds AppHost TS examples for volumes/bind mounts and parameter-based password persistence. |
| src/frontend/src/content/docs/fundamentals/health-checks.mdx | Adds multi-language consuming examples and TS AppHost examples for HTTP-based health checks and orchestration. |
| src/frontend/src/content/docs/fundamentals/external-parameters.mdx | Adds AppHost TS examples and multi-language consuming examples for parameter consumption patterns. |
| src/frontend/src/content/docs/extensibility/interaction-service.mdx | Adds a TS SDK availability note for interaction service APIs. |
| src/frontend/src/content/docs/dashboard/security-considerations.mdx | Adds multi-language examples for configuring OTLP API key headers. |
| src/frontend/src/content/docs/architecture/resource-api-patterns.mdx | Adds AppHost TS examples to illustrate resource API patterns alongside C#. |
Comments suppressed due to low confidence (5)
src/frontend/src/content/docs/fundamentals/service-discovery.mdx:225
- This Go DNS SRV snippet isn’t valid Go as shown (an
importstatement can’t appear by itself mid-file, and it lackspackage main/an import block). Consider rewriting it as a minimal complete example (package + import + lookup) or clearly indicate it’s a fragment.
```go title="Go — main.go"
// In Go, use a DNS SRV lookup to resolve service endpoints
import "net"
_, addrs, err := net.LookupSRV("default", "tcp", "basket")
**src/frontend/src/content/docs/fundamentals/service-discovery.mdx:270**
* This Go snippet uses `os.Getenv`/`http.Get` but doesn’t include imports (and assigns `resp`/`err` without using them), so it won’t compile as a standalone `main.go` example. Add the missing imports/handling, or make it clear it’s a fragment.
basketURL := os.Getenv("services__basket__https__0")
resp, err := http.Get(basketURL + "/api/items")**src/frontend/src/content/docs/fundamentals/service-discovery.mdx:278**
* This Python snippet uses `await client.get(...)` but `client` is not defined in the snippet, and top-level `await` isn’t valid in Python. Either include the `httpx.AsyncClient()` setup inside an async function, or provide a synchronous example.
basket_url = os.getenv("services__basket__https__0")
response = await client.get(f"{basket_url}/api/items")**src/frontend/src/content/docs/fundamentals/service-discovery.mdx:307**
* This Go snippet assigns `resp, err := http.Get(...)` but doesn’t use either variable and omits required imports/header for a complete example. Please either handle/discard the returned values and include imports, or mark the snippet as a fragment.
dashboardURL := os.Getenv("services__basket__dashboard__0")
resp, err := http.Get(dashboardURL + "/api/stats")**src/frontend/src/content/docs/fundamentals/service-discovery.mdx:315**
* This Python snippet uses `await client.get(...)` but `client` isn’t defined, and top-level `await` isn’t valid Python. Please update to a valid, self-contained example (async function + client creation) or switch to a synchronous request example.
dashboard_url = os.getenv("services__basket__dashboard__0")
response = await client.get(f"{dashboard_url}/api/stats")</details>
---
💡 <a href="/microsoft/aspire.dev/new/main?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
Comment on lines
+67
to
+69
| // TODO: | ||
| // Consider various code snippets for configuring | ||
| // volumes here and persistent passwords. |
Comment on lines
+95
to
+96
| "sync" | ||
| "time" |
Comment on lines
+193
to
+201
| ```go title="Go — health.go" | ||
| func main() { | ||
| mux := http.NewServeMux() | ||
| mux.HandleFunc("/health", healthHandler) | ||
| mux.HandleFunc("/alive", aliveHandler) | ||
|
|
||
| server := &http.Server{ | ||
| Addr: ":8080", | ||
| Handler: mux, |
Comment on lines
+267
to
+270
| // In Go, use context timeouts for request timeout control | ||
| ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second) | ||
| defer cancel() | ||
| // Use the ctx for your health check logic |
Comment on lines
+515
to
+520
| const pg = await builder.addPostgres('pg').withHealthCheck('mycheck'); | ||
|
|
||
| await builder | ||
| .addProject('myapp', './MyApp/MyApp.csproj') | ||
| .withReference(pg) | ||
| .waitFor(pg); |
Comment on lines
+338
to
+346
| ```go title="Go — main.go" | ||
| connStr := os.Getenv("ConnectionStrings__postgresdb") | ||
| conn, err := pgx.Connect(context.Background(), connStr) | ||
|
|
||
| // Health endpoint returns healthy without checking | ||
| // the database. In Go, health checks are explicit — | ||
| // omit a database ping to disable them. | ||
| http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { | ||
| w.WriteHeader(http.StatusOK) |
Comment on lines
+354
to
+363
| ```python title="Python — app.py" | ||
| conn_str = os.environ.get("ConnectionStrings__postgresdb") | ||
| conn = psycopg2.connect(conn_str) | ||
|
|
||
| # Health endpoint returns healthy without checking | ||
| # the database. In Python, health checks are explicit — | ||
| # omit a database ping to disable them. | ||
| @app.get("/health") | ||
| async def health(): | ||
| return {"status": "Healthy"} |
Comment on lines
+369
to
+380
| ```typescript title="TypeScript — app.ts" | ||
| import pg from 'pg'; | ||
|
|
||
| const pool = new pg.Pool({ | ||
| connectionString: process.env.ConnectionStrings__postgresdb, | ||
| }); | ||
|
|
||
| // Health endpoint returns healthy without checking | ||
| // the database. In TypeScript, health checks are explicit — | ||
| // omit a database ping to disable them. | ||
| app.get('/health', (req, res) => { | ||
| res.type('text/plain').send('Healthy'); |
Comment on lines
+103
to
+106
| dashboardURL := os.Getenv("services__basket__dashboard__0") | ||
|
|
||
| // Use the resolved URLs directly | ||
| resp, err := http.Get(basketURL + "/api/items") |
Comment on lines
+115
to
+124
| import os | ||
| import httpx | ||
|
|
||
| # Aspire injects endpoint URLs as environment variables. | ||
| # Use the service name to construct the variable name. | ||
| basket_url = os.getenv("services__basket__https__0") | ||
| dashboard_url = os.getenv("services__basket__dashboard__0") | ||
|
|
||
| async with httpx.AsyncClient() as client: | ||
| response = await client.get(f"{basket_url}/api/items") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added TypeScript, Go, and Python example code to the following files:
Examples have been checked using the docs-tester skill.
Fixes: #935