-
Notifications
You must be signed in to change notification settings - Fork 332
Convert markdown to XML documentation syntax in C# emitter #9401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
|
|
||
| // Check for markdown-converted XML tags | ||
| // Bold: <b>, </b> | ||
| if (slice.StartsWith("<b>".AsSpan(), StringComparison.Ordinal) || slice.StartsWith("</b>".AsSpan(), StringComparison.Ordinal)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should consider hoisting all the allowed tags into some HashSet or const class somewhere.
| listItems.Add(ConvertInlineMarkdown(trimmedLine.Substring(2))); | ||
| } | ||
| // Check for numbered list item (e.g., "1. ", "2. ") | ||
| else if (Regex.IsMatch(trimmedLine, @"^\d+\.\s")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider hoisting the RegEx and making it a static pre-compiled?
C# XML documentation doesn't support markdown syntax. The emitter was generating markdown (
**bold**,*italic*,- bullets) in XML doc comments, causing incorrect rendering in IntelliSense and documentation tools.Changes
DocHelpers.cs
ConvertMarkdownToXml()to transform markdown syntax to XML tags**bold**→<b>,*italic*→<i>,***both***→<b><i>- item→<list type="bullet">,1. item→<list type="number">XmlDocStatement.cs
SkipValidTag()to recognize converted XML tags (<b>,<i>,<list>,<item>,<description>)DocHelpersTests.cs
Example
Before:
After:
Original prompt
💡 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.