Fix AspireExport coverage for hosting integrations#15114
Fix AspireExport coverage for hosting integrations#15114sebastienros merged 10 commits intorelease/13.2from
Conversation
Enable the AspireExport analyzer for Aspire.Hosting projects and resolve the diagnostics it reported across the affected integrations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15114Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15114" |
There was a problem hiding this comment.
Pull request overview
This PR turns on the Aspire.Hosting.Analyzers (AspireExport/ATS compatibility analyzer) for all Aspire.Hosting.* projects under src/, then updates multiple hosting integrations to eliminate ASPIREEXPORT diagnostics by explicitly exporting, ignoring, or making ATS-friendly overloads/DTOs available for polyglot SDK generation.
Changes:
- Enable
Aspire.Hosting.Analyzersas an analyzer reference forAspire.Hosting.*projects viasrc/Directory.Build.targets. - Add/adjust
[AspireExport]/[AspireExportIgnore]attributes and collision-safe export IDs across hosting integrations. - Add ATS-friendly overloads (notably in YARP path transforms and Azure Web PubSub event handler APIs) and mark required option/model types as
[AspireDto].
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Directory.Build.targets | Adds conditional analyzer ProjectReference so Aspire.Hosting.* projects run the AspireExport analyzer by default. |
| src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/PathTransformExtensions.cs | Ignores PathString overloads for polyglot and introduces string-based ATS-friendly overloads with exports. |
| src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs | Exports WithDebugging for polyglot use. |
| src/Aspire.Hosting.Maui/MauiHostingExtensions.cs | Marks MAUI hosting services hook as not available for polyglot ([AspireExportIgnore]). |
| src/Aspire.Hosting.DevTunnels/DevTunnelOptions.cs | Marks DevTunnelOptions as [AspireDto] for ATS serialization. |
| src/Aspire.Hosting.Azure/ExistingAzureResourceExtensions.cs | Adjusts export ID to be collision-safe while preserving generated method name via MethodName. |
| src/Aspire.Hosting.Azure/AzureUserAssignedIdentityExtensions.cs | Adjusts export ID to be collision-safe while preserving generated method name via MethodName. |
| src/Aspire.Hosting.Azure.WebPubSub/AzureWebPubSubExtensions.cs | Ignores ATS-incompatible overloads and adds an ATS-friendly exported event handler overload (no auth settings). |
| src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkExtensions.cs | Adds exports for VNet/subnet APIs and related helpers; introduces collision-safe IDs where needed. |
| src/Aspire.Hosting.Azure.Network/AzureSecurityRule.cs | Marks AzureSecurityRule as [AspireDto] for ATS serialization. |
| src/Aspire.Hosting.Azure.Network/AzurePublicIPAddressExtensions.cs | Exports AddPublicIPAddress for polyglot usage. |
| src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointExtensions.cs | Exports AddPrivateEndpoint for polyglot usage. |
| src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityGroupExtensions.cs | Exports NSG creation and security rule APIs. |
| src/Aspire.Hosting.Azure.Network/AzureNatGatewayExtensions.cs | Exports NAT gateway creation and public IP association APIs. |
| src/Aspire.Hosting.Azure.ContainerRegistry/AzureContainerRegistryExtensions.cs | Adjusts export ID for WithAzureContainerRegistry to be collision-safe. |
| src/Aspire.Hosting.Azure.AIFoundry/AzureAIFoundryExtensions.cs | Adds exports for AI Foundry APIs and ignores ATS-incompatible overload(s) where needed. |
| src/Aspire.Hosting.Azure.AIFoundry/AzureAIFoundryDeploymentResource.cs | Exposes deployment resource properties to ATS and ignores the non-polyglot Parent property. |
| src/Aspire.Hosting.Azure.AIFoundry/AIFoundryModel.cs | Marks AIFoundryModel as [AspireDto] for ATS serialization. |
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
| /// Adds the transform which sets the request path with the given value. | ||
| /// </summary> | ||
| [AspireExport("withTransformPathSet", Description = "Adds the transform which sets the request path with the given value.")] | ||
| /// <remarks>This overload is not available in polyglot app hosts. Use the string-based overload instead.</remarks> |
There was a problem hiding this comment.
I don't think these remarks provide any value since it doesn't apply to C# and the AspireExportIgnore won't expose them in other languages.
There was a problem hiding this comment.
We decided to remove them once we have a story for polyglot documentation
Exclude helper Aspire.Hosting projects from the shared analyzer wiring so AppHostAnalyzer only runs on the intended integration-style projects. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit 173298d. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make AppHostAnalyzer skip model-name analysis when Aspire.Hosting model-name types are unavailable, and add a regression test covering projects without the Aspire.Hosting reference. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22967699685 |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| /// <param name="endpoint">The endpoint target for this cluster.</param> | ||
| /// <returns></returns> | ||
| /// <remarks>This overload is not available in polyglot app hosts. Use the <c>addClusterFromEndpoint</c> helper instead.</remarks> | ||
| [AspireExportIgnore(Reason = "Use the explicit static export to avoid AddCluster capability ID collisions in polyglot app hosts.")] |
There was a problem hiding this comment.
Would it make sense to not ExposeMethods and just use the extensions for everything?
| /// <param name="builder">The builder instance.</param> | ||
| /// <param name="cluster">The target cluster for this route.</param> | ||
| /// <returns></returns> | ||
| public static YarpRoute AddRoute(this IYarpConfigurationBuilder builder, YarpCluster cluster) |
There was a problem hiding this comment.
Why aren't we exposing the rest of these methods?
| IMethodSymbol targetMethod, | ||
| [NotNullWhen(true)] out (IParameterSymbol ModelNameParameter, ModelType[] ModelTypes)[]? parameterData) | ||
| { | ||
| if (!wellKnownTypes.TryGet(WellKnownTypeData.WellKnownType.Aspire_Hosting_ApplicationModel_IModelNameParameter, out var modelNameParameter) || |
There was a problem hiding this comment.
When is this analyzer used, but these types can't be found?
| /// <param name="builder">The builder instance.</param> | ||
| /// <param name="cluster">The target cluster for this route.</param> | ||
| /// <returns></returns> | ||
| public static YarpRoute AddRoute(this IYarpConfigurationBuilder builder, YarpCluster cluster) |
There was a problem hiding this comment.
Why isn't the analyzer flagging these methods?
Refresh the YARP validation playground to use the exported helper surface and update code generation snapshots for the current exported APIs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| /// <param name="builder">The builder instance.</param> | ||
| /// <param name="resource">The resource target for this cluster.</param> | ||
| /// <returns>The created cluster.</returns> | ||
| [AspireExport("addClusterFromResource", MethodName = "addCluster", Description = "Adds a YARP cluster for a resource that supports service discovery.")] |
There was a problem hiding this comment.
why is this one have a MethodName?
Description
AspireExportanalyzer fromsrc/Directory.Build.targetsforAspire.Hosting.*projectsASPIREEXPORTdiagnosticsFixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: