Skip to content

Commit 27531ee

Browse files
Copilotlive1206
andauthored
Add enhanced XML documentation to MPG generator Get methods in Mockable extensions (#53549)
* Initial plan * Add enhanced XML documentation to MPG generator Get methods - Updated MockableResourceProvider.BuildGetMethod to copy XML documentation - Get methods in Mockable extension classes now include detailed documentation - Documentation includes Request Path, Operation Id, and Default Api Version - All test projects regenerated and verified Co-authored-by: live1206 <[email protected]> * Add enhanced XML documentation to singleton resource getter methods - Updated MockableResourceProvider to copy XmlDocs from singleton resource Get methods - Singleton getters like GetFooSettings() now include detailed documentation - Documentation includes Request Path, Operation Id, Default Api Version, and Resource Co-authored-by: live1206 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: live1206 <[email protected]>
1 parent eacc763 commit 27531ee

File tree

4 files changed

+244
-15
lines changed

4 files changed

+244
-15
lines changed

eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Providers/MockableResourceProvider.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,19 @@ private IEnumerable<MethodProvider> BuildMethodsForResource(ResourceClientProvid
233233
resource.Type,
234234
This.As<ArmResource>().Client(),
235235
BuildSingletonResourceIdentifier(This.As<ArmResource>().Id(), resource.ResourceTypeValue, resource.SingletonResourceName!)));
236-
yield return new MethodProvider(
236+
var method = new MethodProvider(
237237
resourceMethodSignature,
238238
bodyStatement,
239239
this);
240+
241+
// Copy the enhanced XML documentation from the singleton resource's Get method if available
242+
var getMethod = resource.Methods.FirstOrDefault(m => m.Signature.Name == "Get");
243+
if (getMethod?.XmlDocs?.Summary != null)
244+
{
245+
method.XmlDocs?.Update(summary: getMethod.XmlDocs.Summary);
246+
}
247+
248+
yield return method;
240249
}
241250
else
242251
{
@@ -278,11 +287,19 @@ static MethodProvider BuildGetMethod(TypeProvider enclosingType, MethodProvider
278287
[.. pathParameters, .. resourceGetMethod.Signature.Parameters],
279288
Attributes: [new AttributeStatement(typeof(ForwardsClientCallsAttribute))]);
280289

281-
return new MethodProvider(
290+
var method = new MethodProvider(
282291
signature,
283292
// invoke on a MethodSignature would handle the async extra calls and keyword automatically
284293
Return(This.Invoke(collectionGetSignature).Invoke(resourceGetMethod.Signature)),
285294
enclosingType);
295+
296+
// Copy the enhanced XML documentation from the collection's Get method
297+
if (resourceGetMethod.XmlDocs?.Summary != null)
298+
{
299+
method.XmlDocs?.Update(summary: resourceGetMethod.XmlDocs.Summary);
300+
}
301+
302+
return method;
286303
}
287304
}
288305
}

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableAzureGeneratorMgmtTypeSpecTestsResourceGroupResource.cs

Lines changed: 157 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableAzureGeneratorMgmtTypeSpecTestsSubscriptionResource.cs

Lines changed: 34 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableAzureGeneratorMgmtTypeSpecTestsTenantResource.cs

Lines changed: 34 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)