Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 17, 2025

Description

Extension methods in the Azure Management Generator were missing XML documentation to guide users on mocking. The previous generator included this documentation in an <item> block within the <summary> tag, but the new TypeSpec-based generator omitted it.

Changes

  • ExtensionProvider.cs: Modified BuildRedirectMethod to generate mocking documentation for all extension methods
    • Changed signature to accept MockableResourceProvider instead of CSharpType to access mockable type metadata
    • Added AddMockingDocumentation method to inject <item> block with mocking instructions
    • Added BuildMockingDescription helper to construct method references with parameter types

Generated Output

Extension methods now include mocking guidance:

/// <summary>
/// Gets an object representing a <see cref="FooResource"/> along with the instance operations...
/// <item>
/// <term> Mocking. </term>
/// <description> To mock this method, please mock <see cref="MockableFooArmClient.GetFooResource(ResourceIdentifier)"/> instead. </description>
/// </item>
/// </summary>
public static FooResource GetFooResource(this ArmClient client, ResourceIdentifier id)

Applies to all ARM extension methods across ArmClient, ResourceGroupResource, SubscriptionResource, TenantResource, and ManagementGroupResource.


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

SDK Generation Guidelines

  • If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
  • The generate.cmd file for the SDK has been updated with the version of AutoRest, as well as the commitid of your swagger spec or link to the swagger spec, used to generate the code.
  • The *.csproj and AssemblyInfo.cs files have been updated with the new version of the SDK.
Original prompt

This section details on the original issue you should resolve

<issue_title>[Azure Mgmt Generator] Methods in extension classes missing mocking related doc</issue_title>
<issue_description>Image
This is how it should look like on a method generated by our previous generator:

        /// <summary>
        /// Gets an object representing a <see cref="ComputeLimitSharedLimitResource" /> along with the instance operations that can be performed on it but with no data.
        /// You can use <see cref="ComputeLimitSharedLimitResource.CreateResourceIdentifier" /> to create a <see cref="ComputeLimitSharedLimitResource" /> <see cref="ResourceIdentifier" /> from its components.
        /// <item>
        /// <term>Mocking</term>
        /// <description>To mock this method, please mock <see cref="MockableComputeLimitArmClient.GetComputeLimitSharedLimitResource(ResourceIdentifier)"/> instead.</description>
        /// </item>
        /// </summary>
        /// <param name="client"> The <see cref="ArmClient" /> instance the method will execute against. </param>
        /// <param name="id"> The resource ID of the resource to get. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="client"/> is null. </exception>
        /// <returns> Returns a <see cref="ComputeLimitSharedLimitResource"/> object. </returns>
        public static ComputeLimitSharedLimitResource GetComputeLimitSharedLimitResource(this ArmClient client, ResourceIdentifier id)
        {
            Argument.AssertNotNull(client, nameof(client));

            return GetMockableComputeLimitArmClient(client).GetComputeLimitSharedLimitResource(id);
        }
```</issue_description>

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

<comments>
</comments>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…nerator

Co-authored-by: ArcturusZhang <10554446+ArcturusZhang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add mocking related documentation to extension methods [Azure Mgmt Generator] Add mocking documentation to extension methods Nov 17, 2025
Copilot finished work on behalf of ArcturusZhang November 17, 2025 06:01
Copilot AI requested a review from ArcturusZhang November 17, 2025 06:01
@ArcturusZhang ArcturusZhang marked this pull request as ready for review November 24, 2025 02:44
Copilot AI review requested due to automatic review settings November 24, 2025 02:44
Copilot finished reviewing on behalf of ArcturusZhang November 24, 2025 02:47
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 adds mocking documentation to extension methods generated by the Azure Management Generator. Previously, these extension methods lacked guidance on how users should mock them for testing purposes. The implementation adds an <item> block within the XML <summary> tag to direct users to mock the corresponding method in the mockable resource provider instead.

Key Changes:

  • Modified BuildRedirectMethod to accept MockableResourceProvider instead of just CSharpType to access mockable type metadata
  • Added AddMockingDocumentation method to inject mocking instructions into method XML documentation
  • Added BuildMockingDescription helper to construct method references with parameter type information

Reviewed changes

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

File Description
eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Providers/ExtensionProvider.cs Modified to generate mocking documentation for extension methods, including new methods to build and inject XML documentation
eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/AzureGeneratorMgmtTypeSpecTestsExtensions.cs Test output showing generated mocking documentation added to all extension methods across various ARM resource types

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.

[Azure Mgmt Generator] Methods in extension classes missing mocking related doc

4 participants