Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 17, 2026

Implement markdown to XML doc conversion for C# documentation

Successfully implemented the missing functionality for Documentation spector scenarios. C# XML documentation doesn't support markdown syntax, so we now convert markdown to proper XML tags.

Complete Implementation:

  • Understand the problem and current implementation
  • Implement markdown to XML conversion in DocHelpers.cs
    • Convert **bold**<b>bold</b>
    • Convert *italic*<i>italic</i>
    • Convert ***bold italic***<b><i>bold italic</i></b>
    • Convert - bullet<list type="bullet">...
    • Convert 1. numbered<list type="number">...
  • Update XmlDocStatement.cs to preserve XML tags (not escape them)
  • Add comprehensive unit tests (16 tests, all passing)
  • Add reflection-based validation in SpectorTest methods to verify documentation conversion
  • Regenerate Documentation test project with proper XML
  • Validate generated code has correct XML formatting
  • Applied PR feedback:
    • Refactored XmlDocStatement.cs to use HashSet for allowed XML tags
    • Refactored DocHelpers.cs to use static pre-compiled regex patterns
    • Added reflection-based validation directly in each corresponding SpectorTest method for both enums and methods
    • Merged all documentation tests into single DocumentationTests.cs file

Files Changed:

  1. DocHelpers.cs - Added ConvertMarkdownToXml() with static pre-compiled regex
  2. XmlDocStatement.cs - Extended SkipValidTag() using HashSet for maintainability
  3. DocHelpersTests.cs - 16 unit tests for conversion logic
  4. DocumentationTests.cs - Merged file containing all 6 SpectorTests with validation for both enums and methods
  5. BulletPointsEnum.cs - Regenerated with proper XML documentation

Test Results:

✅ All 16 DocHelpers unit tests passing
✅ All 6 SpectorTests include reflection-based validation for both method and enum documentation
✅ Build succeeds without errors
✅ Generated documentation has proper XML tags
✅ XML tags are not escaped (no &lt; or &gt;)

The implementation is complete and ready for review!

Original prompt

This section details on the original issue you should resolve

<issue_title>Adopt Documentation spector scenarios</issue_title>
<issue_description>https://github.com/microsoft/typespec/tree/main/packages/http-specs/specs/documentation</issue_description>

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


💡 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.

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Adopt documentation spector scenarios Add C# tests for Documentation spector scenarios Jan 17, 2026
Copilot AI requested a review from JoshLove-msft January 17, 2026 18:33
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Copilot AI changed the title Add C# tests for Documentation spector scenarios Convert markdown to XML documentation syntax in C# emitter Jan 17, 2026
@JoshLove-msft JoshLove-msft marked this pull request as ready for review January 17, 2026 19:44
…terns

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jan 21, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 21, 2026

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/http@9401
npm i https://pkg.pr.new/microsoft/typespec/@typespec/http-client@9401
npm i https://pkg.pr.new/microsoft/typespec/@typespec/http-client-csharp@9401

commit: 98a905c

@github-actions
Copy link
Contributor

No changes needing a change description found.

@JoshLove-msft JoshLove-msft added this pull request to the merge queue Jan 21, 2026
Merged via the queue into main with commit d601219 Jan 21, 2026
33 checks passed
@JoshLove-msft JoshLove-msft deleted the copilot/adopt-documentation-spector-scenarios branch January 21, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt Documentation spector scenarios

4 participants