-
Notifications
You must be signed in to change notification settings - Fork 855
ATS capability scanner drops overloaded methods with same MethodName instead of disambiguating #15150
Description
Description
The FilterMethodNameCollisions() method in AtsCapabilityScanner.cs (lines 827-887) drops capabilities when multiple exports share the same MethodName, instead of disambiguating them with numeric suffixes.
Root Cause
When multiple [AspireExport] attributes map to the same MethodName for the same target type, the scanner:
- Groups by
(TargetType, MethodName) - Sorts by
CapabilityIdalphabetically - Keeps only the first, removes the rest with a warning diagnostic
For example, ParameterResourceBuilderExtensions has:
[AspireExport("addParameter", Description = "Adds a parameter resource")]
public static IResourceBuilder<ParameterResource> AddParameter(... string name, bool secret = false)
[AspireExport("addParameterWithValue", MethodName = "addParameter", Description = "Adds a parameter with a default value")]
public static IResourceBuilder<ParameterResource> AddParameter(... string name, string value, bool publishValueAsDefault = false, bool secret = false)Both have MethodName = "addParameter". The scanner keeps addParameter (alphabetically first) and silently drops addParameterWithValue.
Expected Behavior
The scanner should disambiguate colliding methods with numeric suffixes (e.g., addParameter and addParameter1), matching the behavior of the TypeScript code generator's RegisterOptionsInterface which already uses this pattern for options interfaces (AddParameterOptions, AddParameter1Options).
Note: The playground's pre-generated SDK (generated from source via a different code path) correctly produces both addParameter and addParameter1. Only the runtime SDK (generated via the ATS server's capability enumeration) drops the overload.
Impact
Users of TypeScript/polyglot AppHosts cannot use AddParameter with a default value. The parameter overload is silently unavailable with no user-facing error message. This also likely affects other methods with the same pattern (e.g., any [AspireExport] with a MethodName override that matches an existing export).
Reproduction
- Create a TypeScript AppHost with
addParametercalls - Run
aspire run - The generated
.modules/aspire.tswill haveaddParameter(name, {secret})andaddParameterFromConfigurationbut no overload for providing a default value
Environment
- Aspire CLI:
13.2.0-preview.1.26161.4 - Code location:
src/Aspire.Hosting/Ats/AtsCapabilityScanner.cs,FilterMethodNameCollisions()method