Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Add Enhanced Documentation to MPG Generator

Summary

Added detailed XML documentation to operation methods in the Azure Management Plane Generator (MPG), including Request Path, Operation Id, Default Api Version, and Resource information using structured XmlDocStatement objects.

Implementation

  • Created BuildEnhancedXmlDocs method in ResourceOperationMethodProvider
  • Uses XmlDocStatement API to construct structured XML documentation
  • Builds list with items for metadata (Request Path, Operation Id, API Version, Resource)
  • Updates XmlDocs with XmlDocSummaryStatement for proper XML rendering
  • Builds and compiles successfully
  • All required information is included in documentation
  • Merged latest main branch and resolved conflicts
  • Regenerated test projects with proper XML documentation
  • Removed dead code and simplified implementation

Approach

The implementation uses the XmlDocStatement API from the TypeSpec generator to build structured XML documentation instead of raw FormattableString content. This ensures XML tags are rendered properly without HTML encoding issues.

Code Structure:

  1. Creates individual XmlDocStatement objects for each list item (<item>, <term>, <description>)
  2. Wraps items in a list statement with <list type="bullet"> tags
  3. Combines base description with list in an XmlDocSummaryStatement
  4. Updates the method's XmlDocs with the structured summary via existingXmlDocs.Update(summary: summaryStatement)

This approach matches the pattern used in PropertyDescriptionBuilder.cs from the TypeSpec generator and ensures proper XML rendering in the generated code.

Generated Output

The generated documentation now properly renders XML tags:

/// <summary>
/// Get a Bar
/// <list type="bullet">
/// <item>
/// <term> Request Path. </term>
/// <description> /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MgmtTypeSpec/foos/{fooName}/bars/{barName}. </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="BarResource"/>. </description>
/// </item>
/// </list>
/// </summary>

Fixes #53219

Original prompt

This section details on the original issue you should resolve

<issue_title>Some documentation missing in new MPG generator</issue_title>
<issue_description>The expected summary is

/// <summary>
/// Gets information about the specified pool.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Pool_Get</description>
/// </item>
/// <item>
/// <term>Default Api Version</term>
/// <description>2024-07-01</description>
/// </item>
/// <item>
/// <term>Resource</term>
/// <description><see cref="BatchAccountPoolResource"/></description>
/// </item>
/// </list>
/// </summary>

The corresponding description population logic is https://github.com/Azure/autorest.csharp/blob/d93297d16162903b0f2647f890a5db99535e2009/src/AutoRest.CSharp/Mgmt/Models/MgmtClientOperation.cs#L138-L196

The current summary is

Update Azure.Generator.Management to generate expected description.</issue_description>

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

Fixes #53219


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Update Azure.Generator.Management to generate expected description Add enhanced XML documentation to MPG generator operation methods Oct 24, 2025
Copilot AI requested a review from live1206 October 24, 2025 08:05
Copilot finished work on behalf of live1206 October 24, 2025 08:05
Copilot AI requested a review from live1206 October 24, 2025 08:23
Copilot finished work on behalf of live1206 October 24, 2025 08:23
Instead of using FormattableString with raw XML tags that get HTML-encoded,
now using XmlDocStatement API to construct structured XML documentation.
This ensures proper XML rendering without encoding issues.

- Created BuildEnhancedXmlDocs method that constructs XmlDocStatement objects
- Builds list with items for Request Path, Operation Id, API Version, and Resource
- Uses XmlDocSummaryStatement to properly wrap the summary content
- XmlDocs.Update() is called to update the summary with structured statements

This addresses the reviewer's feedback to use XmlDocStatement construction.

Co-authored-by: live1206 <[email protected]>
Copilot finished work on behalf of live1206 October 24, 2025 08:52
@live1206
Copy link
Member

@copilot merge latest main branch and resolve the conflicts.
regenerate the test project to reflect the latest generator change.

Copilot AI and others added 2 commits October 24, 2025 09:16
After merging main branch and resolving conflicts, regenerated all test projects
to reflect the updated generator changes. The XML documentation now uses proper
XmlDocStatement construction, resulting in correctly formatted XML tags instead
of HTML-encoded entities.

Generated documentation now properly shows:
- <list type="bullet"> instead of &lt;list type="bullet"&gt;
- <item>, <term>, <description> tags without encoding
- Properly formatted operation metadata (Request Path, Operation Id, API Version, Resource)

Co-authored-by: live1206 <[email protected]>
Copy link
Contributor Author

Copilot AI commented Oct 24, 2025

@copilot merge latest main branch and resolve the conflicts.
regenerate the test project to reflect the latest generator change.

Merged latest main branch and regenerated test projects. The merge had one conflict in FooResource.cs which was resolved by accepting the main version and regenerating. All test projects now reflect the updated generator with proper XML documentation using XmlDocStatement construction.

The generated documentation now correctly shows XML tags without HTML encoding:

  • <list type="bullet"> instead of &lt;list type="bullet"&gt;
  • Proper <item>, <term>, <description> tags
  • All operation metadata included (Request Path, Operation Id, API Version, Resource)

Commits:

  • ed55ee7: Merge main branch
  • 86836c3: Regenerate test projects with proper XML documentation

Copilot finished work on behalf of live1206 October 24, 2025 09:23
@live1206 live1206 marked this pull request as ready for review October 24, 2025 09:36
@Copilot Copilot AI review requested due to automatic review settings October 24, 2025 09:36
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

Adds enhanced XML documentation to Azure Management Plane Generator operation methods, including Request Path, Operation Id, Default Api Version, and Resource information using structured XmlDocStatement objects for proper XML rendering.

  • Implements BuildEnhancedXmlDocs method using structured XmlDocStatement API instead of raw strings
  • Updates operation method documentation with metadata in a bulleted list format
  • Calls BuildEnhancedXmlDocs during implicit conversion to MethodProvider to apply documentation

- Removed BuildEnhancedDescription method which was a no-op
- Changed line 87 to use original assignment: _description = description ?? _convenienceMethod.Signature.Description
- Changed BuildEnhancedXmlDocs return type from XmlDocProvider? to void since return value is not used
- Simplified method by directly updating existingXmlDocs instead of returning it

Addresses reviewer feedback to remove redundant code.

Co-authored-by: live1206 <[email protected]>
Copilot AI requested a review from live1206 October 27, 2025 02:30
Copilot finished work on behalf of live1206 October 27, 2025 02:30
@live1206
Copy link
Member

/check-enforcer override

@live1206 live1206 merged commit 91b92c2 into main Oct 27, 2025
24 checks passed
@live1206 live1206 deleted the copilot/update-docs-in-mpg-generator branch October 27, 2025 03:37
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.

Some documentation missing in new MPG generator

4 participants