Remove redundant id in AspireExportAttribute usages#15769
Remove redundant id in AspireExportAttribute usages#15769AndriySvyryd merged 10 commits intomainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15769Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15769" |
There was a problem hiding this comment.
Pull request overview
This PR standardizes [AspireExport] usage by removing redundant id arguments (when they simply restated the camel-cased method name) and updating the runtime scanner/analyzer to derive the effective export ID when id is omitted.
Changes:
- Update ATS runtime capability scanning to derive the capability
idfrom the method name when not explicitly provided. - Update the
AspireExportAnalyzerto use the effective/derived export ID for duplicate detection, aligning[AspireExport]with[AspireExport("addThing")]. - Remove redundant
idarguments across many Aspire exports and adjust tests/docs accordingly.
Reviewed changes
Copilot reviewed 109 out of 109 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.RemoteHost.Tests/CapabilityDispatcherTests.cs | Removes redundant id arguments in test capability exports to validate derived IDs. |
| tests/Aspire.Hosting.RemoteHost.Tests/AttributeDataReaderTests.cs | Switches a test export to [AspireExport] (no explicit id). |
| tests/Aspire.Hosting.RemoteHost.Tests/AtsCapabilityScannerTests.cs | Removes redundant id arguments in scanner tests to validate derived IDs. |
| tests/Aspire.Cli.EndToEnd.Tests/ProjectReferenceTests.cs | Updates an E2E test integration export to omit redundant id. |
| src/Aspire.Hosting/RequiredCommandResourceExtensions.cs | Removes redundant id for an exported builder extension. |
| src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs | Removes redundant id arguments from multiple exported builder extensions. |
| src/Aspire.Hosting/Pipelines/PipelineStepFactoryExtensions.cs | Removes redundant id arguments from pipeline-related exports. |
| src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs | Removes redundant id arguments from parameter/connection-string related exports. |
| src/Aspire.Hosting/OtlpConfigurationExtensions.cs | Removes redundant id from OTLP exporter export. |
| src/Aspire.Hosting/McpServerResourceBuilderExtensions.cs | Removes redundant id from MCP server export. |
| src/Aspire.Hosting/ExternalServiceBuilderExtensions.cs | Removes redundant id from external service export. |
| src/Aspire.Hosting/ExecutableResourceBuilderExtensions.cs | Removes redundant id arguments from executable-related exports. |
| src/Aspire.Hosting/DotnetToolResourceExtensions.cs | Removes redundant id arguments from dotnet-tool exports. |
| src/Aspire.Hosting/DistributedApplication.cs | Removes redundant id from CreateBuilder export. |
| src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs | Removes redundant id arguments from container-related exports. |
| src/Aspire.Hosting/ContainerRegistryResourceBuilderExtensions.cs | Removes redundant id arguments from container-registry exports. |
| src/Aspire.Hosting/Ats/UserSecretsExports.cs | Removes redundant id arguments from ATS user-secrets exports. |
| src/Aspire.Hosting/Ats/PipelineExports.cs | Removes redundant id arguments from ATS pipeline exports. |
| src/Aspire.Hosting/Ats/NotificationExports.cs | Removes redundant id arguments from ATS notification exports. |
| src/Aspire.Hosting/Ats/ModelExports.cs | Removes redundant id arguments from ATS model exports. |
| src/Aspire.Hosting/Ats/LoggingExports.cs | Removes redundant id arguments from ATS logging exports. |
| src/Aspire.Hosting/Ats/CoreExports.cs | Removes redundant id arguments from ATS core exports. |
| src/Aspire.Hosting/Ats/BuilderExports.cs | Removes redundant id arguments from ATS builder/config exports. |
| src/Aspire.Hosting/Ats/AspireExportAttribute.cs | Updates XML docs to reflect derived IDs and when explicit id is needed. |
| src/Aspire.Hosting.Yarp/YarpResourceExtensions.cs | Removes redundant id arguments from YARP exports. |
| src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs | Removes redundant id arguments from YARP route exports. |
| src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpCluster.cs | Removes redundant id from YARP cluster export. |
| src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/ResponseTransformExtensions.cs | Removes redundant id arguments from YARP response transform exports. |
| src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/RequestHeadersTransformExtensions.cs | Removes redundant id arguments from YARP request header transform exports. |
| src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/QueryTransformExtensions.cs | Removes redundant id arguments from YARP query transform exports. |
| src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/HttpMethodTransformExtensions.cs | Removes redundant id from YARP HTTP method transform export. |
| src/Aspire.Hosting.Yarp/ConfigurationBuilder/Transforms/ForwardedTransformExtensions.cs | Removes redundant id arguments from YARP forwarded-header transform exports. |
| src/Aspire.Hosting.Valkey/ValkeyBuilderExtensions.cs | Removes redundant id arguments from Valkey exports. |
| src/Aspire.Hosting.Testing/DistributedApplicationHostingTestingExtensions.cs | Removes redundant id from testing helper export. |
| src/Aspire.Hosting.SqlServer/SqlServerBuilderExtensions.cs | Removes redundant id arguments from SQL Server exports. |
| src/Aspire.Hosting.Seq/SeqBuilderExtensions.cs | Removes redundant id arguments from Seq exports. |
| src/Aspire.Hosting.RemoteHost/AtsCapabilityScanner.cs | Changes scanner behavior to derive export IDs when id is omitted. |
| src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs | Removes redundant id arguments from Redis exports. |
| src/Aspire.Hosting.RabbitMQ/RabbitMQBuilderExtensions.cs | Removes redundant id arguments from RabbitMQ exports. |
| src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs | Removes redundant id arguments from Qdrant exports. |
| src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs | Removes redundant id arguments from Python app exports. |
| src/Aspire.Hosting.PostgreSQL/PostgresBuilderExtensions.cs | Removes redundant id arguments from PostgreSQL exports. |
| src/Aspire.Hosting.Orleans/OrleansServiceExtensions.cs | Removes redundant id arguments from Orleans exports. |
| src/Aspire.Hosting.Oracle/OracleDatabaseBuilderExtensions.cs | Removes redundant id arguments from Oracle exports. |
| src/Aspire.Hosting.OpenAI/OpenAIExtensions.cs | Removes redundant id arguments from OpenAI exports. |
| src/Aspire.Hosting.Nats/NatsBuilderExtensions.cs | Removes redundant id arguments from NATS exports. |
| src/Aspire.Hosting.MySql/MySqlBuilderExtensions.cs | Removes redundant id arguments from MySQL exports. |
| src/Aspire.Hosting.MongoDB/MongoDBBuilderExtensions.cs | Removes redundant id arguments from MongoDB exports. |
| src/Aspire.Hosting.Milvus/MilvusBuilderExtensions.cs | Removes redundant id arguments from Milvus exports. |
| src/Aspire.Hosting.Maui/MauiWindowsExtensions.cs | Removes redundant id from MAUI Windows export. |
| src/Aspire.Hosting.Maui/MauiProjectResourceExtensions.cs | Removes redundant id from MAUI project export. |
| src/Aspire.Hosting.Maui/MauiOtlpExtensions.cs | Removes redundant id from MAUI OTLP export. |
| src/Aspire.Hosting.Maui/MauiMacCatalystExtensions.cs | Removes redundant id from MAUI Mac Catalyst export. |
| src/Aspire.Hosting.Maui/MauiiOSExtensions.cs | Removes redundant id arguments from MAUI iOS exports. |
| src/Aspire.Hosting.Maui/MauiAndroidExtensions.cs | Removes redundant id arguments from MAUI Android exports. |
| src/Aspire.Hosting.Kubernetes/KubernetesServiceExtensions.cs | Removes redundant id from Kubernetes service export. |
| src/Aspire.Hosting.Kubernetes/KubernetesEnvironmentExtensions.cs | Removes redundant id arguments from Kubernetes environment exports. |
| src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs | Removes redundant id arguments from Keycloak exports. |
| src/Aspire.Hosting.Kafka/KafkaBuilderExtensions.cs | Removes redundant id arguments from Kafka exports. |
| src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs | Removes redundant id arguments from JavaScript/Node exports. |
| src/Aspire.Hosting.Integration.Analyzers/AspireExportAnalyzer.cs | Uses derived IDs for duplicate detection when id is omitted. |
| src/Aspire.Hosting.GitHub.Models/GitHubModelsExtensions.cs | Removes redundant id from GitHub Models export. |
| src/Aspire.Hosting.Garnet/GarnetBuilderExtensions.cs | Removes redundant id arguments from Garnet exports. |
| src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs | Removes redundant id arguments from Foundry project exports. |
| src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs | Removes redundant id from Foundry hosted agent export. |
| src/Aspire.Hosting.Foundry/FoundryExtensions.cs | Removes redundant id arguments from Foundry exports. |
| src/Aspire.Hosting.Docker/DockerComposeServiceExtensions.cs | Removes redundant id from Docker Compose service export. |
| src/Aspire.Hosting.Docker/DockerComposeEnvironmentExtensions.cs | Removes redundant id arguments from Docker Compose environment exports. |
| src/Aspire.Hosting.Docker/DockerComposeAspireDashboardResourceBuilderExtensions.cs | Removes redundant id arguments from Docker Compose dashboard exports. |
| src/Aspire.Hosting.DevTunnels/DevTunnelResourceBuilderExtensions.cs | Removes redundant id from dev tunnel export. |
| src/Aspire.Hosting.Azure/Provisioning/AzureProvisionerExtensions.cs | Removes redundant id from Azure provisioning export. |
| src/Aspire.Hosting.Azure/ExistingAzureResourceExtensions.cs | Removes redundant id arguments from Azure existing-resource exports. |
| src/Aspire.Hosting.Azure/AzureUserAssignedIdentityExtensions.cs | Removes redundant id from Azure identity export. |
| src/Aspire.Hosting.Azure/AzureResourceExtensions.cs | Removes redundant id arguments from Azure resource exports. |
| src/Aspire.Hosting.Azure/AzureProvisioningResourceExtensions.cs | Removes redundant id arguments from Azure provisioning-resource exports. |
| src/Aspire.Hosting.Azure/AzureEnvironmentResourceExtensions.cs | Removes redundant id arguments from Azure environment exports. |
| src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs | Removes redundant id arguments from Azure Bicep exports. |
| src/Aspire.Hosting.Azure.WebPubSub/AzureWebPubSubExtensions.cs | Removes redundant id arguments from Web PubSub exports. |
| src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs | Removes redundant id arguments from Azure Storage exports. |
| src/Aspire.Hosting.Azure.Sql/AzureSqlExtensions.cs | Removes redundant id arguments from Azure SQL exports. |
| src/Aspire.Hosting.Azure.SignalR/AzureSignalRExtensions.cs | Removes redundant id from Azure SignalR emulator export. |
| src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusExtensions.cs | Removes redundant id arguments from Azure Service Bus exports. |
| src/Aspire.Hosting.Azure.Search/AzureSearchExtensions.cs | Removes redundant id from Azure Search export. |
| src/Aspire.Hosting.Azure.Redis/AzureManagedRedisExtensions.cs | Removes redundant id arguments from Azure Managed Redis exports. |
| src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresExtensions.cs | Removes redundant id arguments from Azure Postgres exports. |
| src/Aspire.Hosting.Azure.OperationalInsights/AzureLogAnalyticsWorkspaceExtensions.cs | Removes redundant id from Log Analytics Workspace export. |
| src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkExtensions.cs | Removes redundant id arguments from Azure VNet/subnet/NSG rule exports. |
| src/Aspire.Hosting.Azure.Network/AzurePublicIPAddressExtensions.cs | Removes redundant id from Azure public IP export. |
| src/Aspire.Hosting.Azure.Network/AzurePrivateEndpointExtensions.cs | Removes redundant id from Azure private endpoint export. |
| src/Aspire.Hosting.Azure.Network/AzureNetworkSecurityGroupExtensions.cs | Removes redundant id arguments from Azure NSG exports. |
| src/Aspire.Hosting.Azure.Network/AzureNatGatewayExtensions.cs | Removes redundant id arguments from Azure NAT gateway exports. |
| src/Aspire.Hosting.Azure.Kusto/AzureKustoReadWriteDatabaseResourceExtensions.cs | Removes redundant id from Kusto script export. |
| src/Aspire.Hosting.Azure.Kusto/AzureKustoBuilderExtensions.cs | Removes redundant id arguments from Kusto exports. |
| src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultResourceExtensions.cs | Removes redundant id arguments from Key Vault exports. |
| src/Aspire.Hosting.Azure.Functions/DurableTask/DurableTaskResourceExtensions.cs | Removes redundant id arguments from Durable Task exports. |
| src/Aspire.Hosting.Azure.Functions/AzureFunctionsProjectResourceExtensions.cs | Removes redundant id arguments from Azure Functions exports. |
| src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsExtensions.cs | Removes redundant id arguments from Event Hubs exports. |
| src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs | Removes redundant id arguments from Cosmos DB exports. |
| src/Aspire.Hosting.Azure.ContainerRegistry/AzureContainerRegistryExtensions.cs | Removes redundant id arguments from ACR exports. |
| src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIExtensions.cs | Removes redundant id arguments from Azure OpenAI exports. |
| src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs | Removes redundant id arguments from App Service environment exports. |
| src/Aspire.Hosting.Azure.AppService/AzureAppServiceComputeResourceExtensions.cs | Removes redundant id arguments from App Service compute exports. |
| src/Aspire.Hosting.Azure.ApplicationInsights/AzureApplicationInsightsExtensions.cs | Removes redundant id arguments from Application Insights exports. |
| src/Aspire.Hosting.Azure.AppContainers/ContainerAppExtensions.cs | Removes redundant id from Container App Job publish export. |
| src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs | Removes redundant id arguments from Container Apps environment exports. |
| src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationExtensions.cs | Removes redundant id arguments from App Configuration exports. |
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
adce063 to
26ad309
Compare
…T011 and effectiveExportId Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/d7430cb3-5ccf-44a2-8d5d-d607612c47f7 Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
JamesNK
left a comment
There was a problem hiding this comment.
Two minor findings (contradictory dual-diagnostic scenario and missing instance-method test coverage for ASPIREEXPORT011). Otherwise LGTM — the analyzer/scanner ID derivation logic is consistent, bulk removals are correct, and disambiguation cases are properly handled.
@sebastienros please also approve before merge.
|
@AndriySvyryd wait on @sebastienros to merge this. |
|
woops |
…hod ExposeMethods=true tests Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/52cb7aa6-8962-4b6e-9695-b3cdad28c19f Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Right now no snapshots or polyglot test apphost are touched, which is a good sign that this isn't breaking anything. When the tests run (currently blocked on conflict) we'll see if anything is impacted. |
Auto-merge should be enabled, otherwise this will constantly be blocked by a conflict |
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
|
🎬 CLI E2E Test Recordings — 55 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23926834693 |
Fixes #15767
Description
[AspireExport("id")]usages were inconsistent — most explicitly repeated the camelCase method name as theid, which is redundant. Theidshould only appear when disambiguation is needed (e.g., multiple overloads mapped to different capability names).Changes
AtsCapabilityScanner: Auto-derives capability ID fromToCamelCase(method.Name)when no explicitidis provided (static methods only). Whenidis explicitly set to an empty/whitespace string, emits a warning and skips the method (restoring original behavior).AspireExportAnalyzer: AddsGetDerivedExportIdto compute the effective export ID for ASPIREEXPORT007 duplicate detection, so[AspireExport]onAddThingcorrectly collides with[AspireExport("addThing")]on another overload. Empty/invalidexportIdvalues are normalized to null before applying the fallback. Caches thes_exportIdPattern.IsMatch(exportId)result in a localisExportIdFormatValidvariable to avoid evaluating the regex twice.GetDerivedExportIdis now called only once per method analysis, with the result stored inderivedExportIdand reused for both the ASPIREEXPORT011 redundancy check and theeffectiveExportIdcomputation.GetDerivedExportIdaccounts for the containing type name: for instance methods the derived ID isTypeName.camelCaseMethod(matching the scanner'sTypeName.methodNamepattern), and for static methods it remainscamelCaseMethod. Rule 7 (ASPIREEXPORT009 — export name uniqueness) now correctly useseffectiveExportIdinstead of the rawexportId, so the uniqueness check is no longer silently skipped for methods without an explicit id.idargument matches the convention-derived name, flagging it as redundant. For static extension methods, the convention iscamelCase(methodName)(e.g.,[AspireExport("addRedis")]onAddRedis). For instance methods on types, the convention isTypeName.camelCase(methodName), so a short explicit id like"getValueAsync"onEndpointReference.GetValueAsyncis not flagged. ASPIREEXPORT011 is suppressed when ASPIREEXPORT009 also fires for the same method — the two diagnostics give contradictory advice ("remove the id" vs. "make the id more specific"), so only the actionable ASPIREEXPORT009 is shown. AHasConcreteResourceBuilderTargetParameterhelper detects this condition.AspireExportAttribute: Updated XML docs —idconstructor overload now documents it's only needed for disambiguation; parameterless constructor documents it works for both methods and types.idarguments whereid == camelCase(methodName)for static extension methods. All disambiguation cases (whereiddiffers) are preserved.Before / After (static extension methods):
Instance methods retain explicit ids (ATS capability ID must stay unchanged):
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: