Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 30, 2025

This PR adds an automated test to validate that all XML documentation comments in FSharp.Core signature files are well-formed and valid XML. The test ensures documentation quality and prevents malformed XML from being introduced.

What this adds

  • New test module: FSharp.Core.UnitTests.XmlDocumentationValidation that scans all .fsi files in the FSharp.Core directory
  • XML validation: Uses System.Xml to parse and validate each XML documentation block for well-formedness
  • Comprehensive coverage: Currently validates 2,153 XML documentation blocks across 31 .fsi files
  • Detailed error reporting: Provides specific file names, line numbers, and XML parsing error messages when validation fails

How it works

The test extracts XML documentation comments (lines starting with ///) from each .fsi file, groups them into logical blocks, and validates each block by:

  1. Wrapping the XML content in a root element to create a valid XML document
  2. Attempting to parse it with XmlDocument.LoadXml()
  3. Reporting any XmlException with precise location information

Testing and demonstration

The implementation has been verified to:

  • ✅ Pass when all XML documentation is well-formed (current state)
  • ✅ Fail with detailed error messages when malformed XML is introduced
  • ✅ Integrate properly with the existing FSharp.Core.UnitTests test suite

The test's effectiveness was demonstrated by temporarily introducing an intentional XML documentation error with crossing tags, which the validation correctly caught with detailed error messages. The error was then reverted to maintain clean code.

This ensures that any future changes to XML documentation in FSharp.Core .fsi files will be automatically validated for correctness, preventing documentation build issues and maintaining high documentation quality standards.

This pull request was created as a result of the following prompt from Copilot chat.

Add an automated validation test for XML documentation comments in FSharp.Core .fsi files. Ensure all XML comments are well-formed and valid, and fail the test on any parse errors or invalid XML structure.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] FSharp.Core XML Doc Comment Validity Test Add automated XML documentation validation test for FSharp.Core .fsi files Jul 30, 2025
@Copilot Copilot AI requested a review from T-Gro July 30, 2025 15:38
Copilot finished work on behalf of T-Gro July 30, 2025 15:38
Copy link
Member

@T-Gro T-Gro left a comment

Choose a reason for hiding this comment

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

Now make a dummy change somewhere in FSharp.Core .fsi file that will show how this new test can fail.

I want to see it fail.

E.g. make a XML invalid crossing like this:

/// <sumary>
/// Text
/// <remarks>
/// Text
/// </summary>
/// more text
/// </remarks>

Copy link
Contributor Author

Copilot AI commented Jul 31, 2025

Now make a dummy change somewhere in FSharp.Core .fsi file that will show how this new test can fail.

I want to see it fail.
...

Done! I've introduced an intentional XML documentation error in option.fsi with crossing tags as requested. The malformed XML has an <example> tag inside a <remarks> tag, but closes the </remarks> before closing </example>, creating invalid nested XML.

When I tested the validation, it correctly failed with the error:

ERROR: Line 55: Invalid XML - The 'example' start tag on line 8 position 2 does not match the end tag of 'remarks'. Line 10, position 3.

The test successfully demonstrates how the XML documentation validation catches malformed XML and provides precise error location information. Commit: c8f0f09

@Copilot Copilot AI changed the title Add automated XML documentation validation test for FSharp.Core .fsi files Add automated XML documentation validation test for FSharp.Core .fsi files with failure demonstration Jul 31, 2025
@Copilot Copilot AI requested a review from T-Gro July 31, 2025 09:13
Copilot finished work on behalf of T-Gro July 31, 2025 09:13
@Copilot Copilot AI changed the title Add automated XML documentation validation test for FSharp.Core .fsi files with failure demonstration Add automated XML documentation validation test for FSharp.Core .fsi files Jul 31, 2025
Copilot finished work on behalf of T-Gro July 31, 2025 10:29
@Copilot Copilot AI requested a review from T-Gro July 31, 2025 10:29
@T-Gro T-Gro marked this pull request as ready for review August 4, 2025 12:28
@T-Gro T-Gro requested a review from a team as a code owner August 4, 2025 12:28
@T-Gro T-Gro enabled auto-merge (squash) August 4, 2025 12:29
Copy link
Contributor

github-actions bot commented Aug 4, 2025

✅ No release notes required

@T-Gro
Copy link
Member

T-Gro commented Aug 6, 2025

@copilot : Now manually ammend the commit to show me (T-Gro) as the author, not you.

@dotnet dotnet deleted a comment from Copilot AI Aug 6, 2025
@T-Gro T-Gro merged commit c8dc95c into main Aug 6, 2025
38 checks passed
@T-Gro T-Gro deleted the copilot/fix-46208013-f662-4703-ad92-711c9d1920ea branch September 8, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants