-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Bug Description
ResourceClientProvider.BuildGetChildResourceMethods() generates collection getter and Get/GetAsync methods for child resources on a parent resource class. When child resources have extra path parameters between the parent and child resource (e.g., nestedResourceTypeFirst), these parameters are:
- Not passed to the collection constructor in the getter method body (line 480)
- Not included in the Get/GetAsync method signatures (line 504-510)
- Not forwarded when calling the collection getter from Get/GetAsync methods (line 515)
Impact
This affects any ARM resource with nested children that have intermediate path segments. For example, ProviderHub has:
ResourceTypeRegistration(parent)NestedResourceTypeFirstSku(child, needsnestedResourceTypeFirstpath param)NestedResourceTypeSecondSku(child, needsnestedResourceTypeFirst+nestedResourceTypeSecond)NestedResourceTypeThirdSku(child, needs 3 path params)
The generated accessor methods either compile with errors or are suppressed via CodeGenSuppress.
Root Cause
File: ResourceClientProvider.cs in Azure.Generator.Management
Collection getter (line 480):
\\csharp
// Only passes client and Id, ignores path parameters from signature
New.Instance(childResource.ResourceCollection.Type, client, thisResource.Id())
\\
Get method signature (line 504-510): Only includes collectionSignature.Parameters (e.g., sku, cancellationToken) but not the path parameters from the collection getter's signature.
Get method body (line 515): Calls thisResource.Invoke(signature.Name) without passing path parameter arguments.
Fix
See PR linked to this issue.