Expose Blazor gateway and Dockerfile factory APIs to ATS#17420
Conversation
Adds ATS/polyglot AppHost coverage for APIs identified in the issue #17049 playground audit, restricted to existing public C# APIs: - Aspire.Hosting.Blazor: tag existing public AddBlazorGateway, WithBlazorClientApp, and AddBlazorWasmApp (exported as addBlazorWasmProject) with [AspireExport]. AddBlazorWasmApp also gains [ResourceName] on its name parameter. - Aspire.Hosting: add internal WithDockerfileFactoryForPolyglot and AddDockerfileFactoryForPolyglot shims tagged [AspireExport] that wrap the existing public WithDockerfileFactory/AddDockerfileFactory methods. The existing public signature takes Func<DockerfileFactoryContext, Task<string>>, which exposes .NET-only types and is not ATS-conventional, so the shims expose a parameterless Func<Task<string>> callback shape instead. Polyglot AppHost fixtures exercise each newly exported export across all four supported languages (Go, Java, Python, TypeScript): - tests/PolyglotAppHosts/Aspire.Hosting.Blazor/{Go,Java,Python,TypeScript} - tests/PolyglotAppHosts/Aspire.Hosting/{Go,Java,Python,TypeScript} (Dockerfile factory usage) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17420Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17420" |
There was a problem hiding this comment.
Pull request overview
This PR expands Aspire Type System (ATS) / polyglot AppHost coverage by exporting existing Blazor gateway APIs and by introducing ATS-exportable shims for Dockerfile factory APIs whose original .NET callback context isn’t polyglot-friendly. It also adds new polyglot fixtures across Go/Java/Python/TypeScript to validate the newly exported surface.
Changes:
- Export Blazor gateway and WASM project APIs to ATS (including applying
[ResourceName]where needed for naming conventions). - Add internal ATS-exported shims for
addDockerfileFactory/withDockerfileFactorythat use a polyglot-friendlyFunc<Task<string>>callback shape. - Add/update polyglot AppHost fixtures to exercise the exported APIs across supported languages.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/PolyglotAppHosts/Aspire.Hosting/TypeScript/apphost.mts | Adds TypeScript fixture usage of addDockerfileFactory / withDockerfileFactory. |
| tests/PolyglotAppHosts/Aspire.Hosting/Python/apphost.py | Adds Python fixture usage of add_dockerfile_factory / with_dockerfile_factory. |
| tests/PolyglotAppHosts/Aspire.Hosting/Java/AppHost.java | Adds Java fixture usage of addDockerfileFactory / withDockerfileFactory. |
| tests/PolyglotAppHosts/Aspire.Hosting/Go/apphost.go | Adds Go fixture usage of AddDockerfileFactory / WithDockerfileFactory. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/TypeScript/tsconfig.json | New TS config for Blazor polyglot fixture compilation. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/TypeScript/package.json | New TS package setup for Blazor polyglot fixture compilation. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/TypeScript/aspire.config.json | New TS Aspire config referencing Aspire.Hosting.Blazor. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/TypeScript/apphost.mts | New TypeScript Blazor fixture exercising gateway + WASM project APIs. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/Python/pylock.apphost.toml | New Python lock metadata for Blazor polyglot fixture. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/Python/aspire.config.json | New Python Aspire config referencing Aspire.Hosting.Blazor. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/Python/apphost.py | New Python Blazor fixture exercising gateway + WASM project APIs. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/Python/apphost_requirements.txt | New fallback pip requirements file for Python Blazor fixture. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/Java/aspire.config.json | New Java Aspire config (enables experimental polyglot Java) referencing Aspire.Hosting.Blazor. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/Java/AppHost.java | New Java Blazor fixture exercising gateway + WASM project APIs. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/Go/go.mod | New Go module file for Blazor polyglot fixture. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/Go/aspire.config.json | New Go Aspire config referencing Aspire.Hosting.Blazor. |
| tests/PolyglotAppHosts/Aspire.Hosting.Blazor/Go/apphost.go | New Go Blazor fixture exercising gateway + WASM project APIs. |
| src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs | Adds ATS-exported internal Dockerfile factory shims for polyglot callbacks. |
| src/Aspire.Hosting.Blazor/Resources/BlazorWasmAppResource.cs | Exports BlazorWasmAppResource to ATS (suppresses experimental warning). |
| src/Aspire.Hosting.Blazor/BlazorGatewayExtensions.cs | Exports Blazor gateway APIs and applies [ResourceName] where needed. |
Drops the internal *ForPolyglot shims in favor of exporting the
existing public WithDockerfileFactory<T> and AddDockerfileFactory
async overloads directly via [AspireExport].
DockerfileFactoryContext is now [AspireExport]-tagged at the class
level with its Resource property exposed to polyglot callers; the
.NET-only Services (IServiceProvider) and CancellationToken stay
unexported. This mirrors how EnvironmentCallbackContext is exposed
to polyglot hosts. The synchronous Func<DockerfileFactoryContext,
string> overloads remain ignored with the same reason used elsewhere
(polyglot uses the async overload).
Polyglot fixtures in tests/PolyglotAppHosts/Aspire.Hosting/{Go,Java,
Python,TypeScript} are updated to use the new context-receiving
callback signature.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The newly [AspireExport]-ed WithDockerfileFactory/AddDockerfileFactory APIs
and the DockerfileFactoryContext type cause the polyglot generators to emit
additional capability bindings. Refresh the affected Verify snapshots so the
Hosting.CodeGeneration.{Go,Java,Python,Rust,TypeScript} test jobs pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
❓ CLI E2E Tests unknown — 96 passed, 0 failed, 5 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26347971530 |
|
Where's the pr-testing report? |
PR Testing Report (dogfood + codegen)Result: ✅ Verified CLI version check
Scenario 1 — Codegen unit tests (5 ATS languages)All 187 tests passed, including
Scenario 2 — PR CLI dogfood smoke test
Notes for the author
Tested locally on macOS via |
Document the newly polyglot-exported APIs from microsoft/aspire#17420: - Add Blazor hosting integration page (integrations/dotnet/blazor-hosting.mdx) covering AddBlazorGateway, WithBlazorClientApp, and AddBlazorWasmProject with C# and TypeScript code examples - Update app-host/withdockerfile.mdx to add a 'Generate a Dockerfile with a factory function' section covering AddDockerfileFactory / WithDockerfileFactory with C# and TypeScript examples - Add Blazor hosting entry to the integrations sidebar Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Pull request created: #1061
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1061 targeting A draft documentation PR has been opened on microsoft/aspire.dev targeting
Triggered signal: Note This draft PR needs human review before merging. |
Description
Adds ATS/polyglot AppHost coverage for a subset of APIs identified in the issue #17049 playground audit. Scope is intentionally restricted to exposing existing public C# APIs to ATS — no new public API surface is invented. Other audit candidates (Kusto
WithControlCommand, YARPWithConfigFile, Foundry/Kubernetes gaps) were investigated but did not have an existing public counterpart that could be exposed without introducing new API surface, so they are deferred.Source changes
AddBlazorGateway,WithBlazorClientApp, andAddBlazorWasmApp(exported asaddBlazorWasmProject) with[AspireExport].AddBlazorWasmAppalso gains[ResourceName]on itsnameparameter so ATS-generated SDKs honor naming conventions.WithDockerfileFactoryForPolyglot/AddDockerfileFactoryForPolyglotshims tagged[AspireExport]. These wrap the existing publicWithDockerfileFactory/AddDockerfileFactorymethods, whose signature takesFunc<DockerfileFactoryContext, Task<string>>—DockerfileFactoryContextexposes .NET-only types (IServiceProvider,IResource) and is not ATS-conventional, so the shims expose a parameterlessFunc<Task<string>>callback shape that polyglot callers can implement.Polyglot validation
Each newly exported API is exercised across all four polyglot languages, with fixtures arranged 1:1 against the source changes:
tests/PolyglotAppHosts/Aspire.Hosting.Blazor/{Go,Java,Python,TypeScript}— new fixture tree coveringaddBlazorGateway,withBlazorClientApp, andaddBlazorWasmProject.tests/PolyglotAppHosts/Aspire.Hosting/{Go,Java,Python,TypeScript}—withDockerfileFactory/addDockerfileFactoryusage validation.Per-language fixture builds (
tsc --noEmit,javac --enable-preview --source 25,go build, Pythoncompile) were validated locally against a regenerated ATS SDK during development.dotnet buildofAspire.HostingandAspire.Hosting.Blazorsucceeds with 0 warnings and 0 errors.Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?