Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 29, 2025

Plan: Add Missing Documentation to MPG Generator Get Methods ✅

This issue addresses missing documentation in the management plane generator (MPG) for Get methods in Mockable extension classes.

Problem

The Get methods in MockableXxxResourceGroupResource.cs files were missing detailed XML documentation that includes:

  • Request Path
  • Operation Id
  • Default Api Version
  • Resource (where applicable)

Analysis

The documentation is generated in ResourceOperationMethodProvider.BuildEnhancedXmlDocs() but this was not being applied to the Get methods created in MockableResourceProvider.BuildGetMethod().

Solution Implemented

  • Understand the issue and identify the root cause
  • Update MockableResourceProvider.BuildGetMethod() to copy enhanced XML documentation for collection-based resources
  • Update MockableResourceProvider.BuildMethodsForResource() to copy enhanced XML documentation for singleton resources
  • Refactor to move XmlDocs retrieval logic into ResourceClientProvider and ResourceCollectionClientProvider
  • Further refactor to move MethodProvider building logic into resource provider classes
  • Regenerate test projects to validate the fix
  • Build and test the generator to ensure no regressions
  • Code review completed with no issues
  • Security scan completed with no issues
  • Address reviewer feedback for singleton resource documentation
  • Address reviewer feedback to centralize logic in resource providers

Changes Made

  1. Added BuildFactoryMethodProvider() method to ResourceClientProvider - builds complete MethodProvider with enhanced XmlDocs for singleton resource factory methods
  2. Added BuildMockableGetMethodProvider() method to ResourceCollectionClientProvider - builds complete MethodProvider with enhanced XmlDocs for collection Get methods
  3. Modified MockableResourceProvider.BuildMethodsForResource() to use ResourceClientProvider.BuildFactoryMethodProvider() for singleton resources
  4. Modified MockableResourceProvider.BuildMethodsForResource() to use ResourceCollectionClientProvider.BuildMockableGetMethodProvider() for collection Get methods
  5. Removed BuildGetMethod() static method from MockableResourceProvider - logic moved to ResourceCollectionClientProvider
  6. Regenerated all test projects - verified that documentation is unchanged and still includes Request Path, Operation Id, Default Api Version, and Resource
  7. Validated all 60 generator tests pass (60/60 succeeded)
  8. Verified no security issues or code review concerns

Before & After - Collection Resources

Before:

/// <summary> Get a Foo. </summary>
public virtual async Task<Response<FooResource>> GetFooAsync(string fooName, CancellationToken cancellationToken = default)

After:

/// <summary>
/// Get a Foo
/// <list type="bullet">
/// <item>
/// <term> Request Path. </term>
/// <description> /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MgmtTypeSpec/foos/{fooName}. </description>
/// </item>
/// <item>
/// <term> Operation Id. </term>
/// <description> Get. </description>
/// </item>
/// <item>
/// <term> Default Api Version. </term>
/// <description> 2024-05-01. </description>
/// </item>
/// </list>
/// </summary>
public virtual async Task<Response<FooResource>> GetFooAsync(string fooName, CancellationToken cancellationToken = default)

Before & After - Singleton Resources

Before:

/// <summary> Gets an object representing a <see cref="FooSettingsResource"/> along with the instance operations that can be performed on it in the <see cref="ResourceGroupResource"/>. </summary>
public virtual FooSettingsResource GetFooSettings()

After:

/// <summary>
/// Get a FooSettings
/// <list type="bullet">
/// <item>
/// <term> Request Path. </term>
/// <description> /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MgmtTypeSpec/FooSettings/default. </description>
/// </item>
/// <item>
/// <term> Operation Id. </term>
/// <description> Get. </description>
/// </item>
/// <item>
/// <term> Default Api Version. </term>
/// <description> 2024-05-01. </description>
/// </item>
/// <item>
/// <term> Resource. </term>
/// <description> <see cref="FooSettingsResource"/>. </description>
/// </item>
/// </list>
/// </summary>
public virtual FooSettingsResource GetFooSettings()

Files Changed

  • ResourceClientProvider.cs - Added BuildFactoryMethodProvider() method
  • ResourceCollectionClientProvider.cs - Added BuildMockableGetMethodProvider() method
  • MockableResourceProvider.cs - Updated to use the new methods, removed BuildGetMethod() static method

Ready for review

Original prompt

This section details on the original issue you should resolve

<issue_title>Documentation missing in new mpg generator</issue_title>
<issue_description>The current documentation

/// <summary> Get a Foo. </summary>
/// <param name="fooName"> The name of the Foo. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="fooName"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="fooName"/> is an empty string, and was expected to be non-empty. </exception>

Expected documentation

/// <summary>
/// Retrieves information about an availability set.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>AvailabilitySets_Get</description>
/// </item>
/// <item>
/// <term>Default Api Version</term>
/// <description>2025-04-01</description>
/// </item>
/// <item>
/// <term>Resource</term>
/// <description><see cref="AvailabilitySetResource"/></description>
/// </item>
/// </list>
/// </summary>
/// <param name="availabilitySetName"> The name of the availability set. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="availabilitySetName"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="availabilitySetName"/> is an empty string, and was expected to be non-empty. </exception>

Follow-up fix of #53219</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- 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]>
Copilot AI changed the title [WIP] Add missing documentation in mpg generator Add enhanced XML documentation to MPG generator Get methods in Mockable extensions Oct 29, 2025
Copilot AI requested a review from live1206 October 29, 2025 00:39
Copilot finished work on behalf of live1206 October 29, 2025 00:39
- 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]>
Copilot AI requested a review from live1206 October 29, 2025 01:06
Copilot finished work on behalf of live1206 October 29, 2025 01:06
@live1206 live1206 marked this pull request as ready for review October 29, 2025 03:52
Copilot AI review requested due to automatic review settings October 29, 2025 03:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances XML documentation for mockable resource methods by copying detailed API documentation from the underlying resource methods. The generator now propagates enhanced XML documentation (including request path, operation ID, API version, and resource information) from collection Get methods and singleton resource Get methods to their corresponding wrapper methods in mockable resource classes.

  • Adds logic to copy XML documentation summaries from source methods to generated wrapper methods in mockable resources
  • Updates generated test files to include enhanced XML documentation with structured lists containing API metadata

Reviewed Changes

Copilot reviewed 1 out of 4 changed files in this pull request and generated 2 comments.

File Description
MockableResourceProvider.cs Implements XML documentation copying for singleton and collection resource Get methods
MockableAzureGeneratorMgmtTypeSpecTestsTenantResource.cs Generated file updated with enhanced XML docs for quota status methods
MockableAzureGeneratorMgmtTypeSpecTestsSubscriptionResource.cs Generated file updated with enhanced XML docs for Playwright quota methods
MockableAzureGeneratorMgmtTypeSpecTestsResourceGroupResource.cs Generated file updated with enhanced XML docs for various resource Get methods

Copilot finished work on behalf of live1206 October 29, 2025 06:26
Copilot finished work on behalf of live1206 October 29, 2025 06:47
@live1206 live1206 force-pushed the copilot/add-documentation-for-mpg-generator branch from e9e5eeb to c0a69b0 Compare October 29, 2025 07:51
@live1206
Copy link
Member

/check-enforcer override

@live1206 live1206 merged commit 27531ee into main Oct 29, 2025
35 of 36 checks passed
@live1206 live1206 deleted the copilot/add-documentation-for-mpg-generator branch October 29, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation missing in new mpg generator

4 participants