Skip to content

Backport System.Text.RegularExpressions XML docs from dotnet-api-docs to source#127038

Merged
danmoseley merged 4 commits intodotnet:mainfrom
danmoseley:runtime-regex-docs
Apr 17, 2026
Merged

Backport System.Text.RegularExpressions XML docs from dotnet-api-docs to source#127038
danmoseley merged 4 commits intodotnet:mainfrom
danmoseley:runtime-regex-docs

Conversation

@danmoseley
Copy link
Copy Markdown
Member

@danmoseley danmoseley commented Apr 16, 2026

Note

This PR description was AI/Copilot-generated.

Motivation

New APIs like RegexOptions.AnyNewLine and RegexOptions.NonBacktracking have documentation in source code but only "To be added." stubs in the dotnet-api-docs repo, so they show up undocumented on learn.microsoft.com. Similarly, GeneratedRegexAttribute members were documented in source but stubbed in the docs repo.

Rather than patch these individually in the docs repo, this PR makes the source code the single source of truth by backporting the richer dotnet-api-docs content into /// comments and flipping the UseCompilerGeneratedDocXmlFile switch. This is part of the broader initiative tracked in dotnet/dotnet-api-docs#10722.

What changed

  • 24 files in src/libraries/System.Text.RegularExpressions/src/ — all changes are XML doc comments (///), with these exceptions:
    • Removed <UseCompilerGeneratedDocXmlFile>false</UseCompilerGeneratedDocXmlFile> from the csproj (flips the switch so compiler-generated XML becomes authoritative)
    • Converted inline // comments on protected fields in Regex.cs to /// XML doc comments (required to avoid CS1591 errors)
    • Removed a // Callback class comment in RegexRunnerFactory.cs (replaced by /// <summary>)
  • No behavioral code changes.

Merge strategy

  • Default: dotnet-api-docs text wins — richer, editor-reviewed content preferred over minimal source stubs
  • Source text kept where docs-repo was missingAnyNewLine, NonBacktracking, GeneratedRegexAttribute members had docs in source but only "To be added." in the docs repo
  • .NET Framework-specific content strippedCompileToAssembly remarks, Framework version notes, etc.

Format conversion

Docs-repo uses a custom XML/Markdown hybrid format. This was converted to standard /// XML:

docs-repo source ///
<format type="text/markdown"> <remarks>, <para>, <list>
Backtick code <c>...</c>
[text](url) <see href="url">text</see>
Markdown tables <list type="table">

Follow-up needed (by docs team)

Per the process in dotnet/dotnet-api-docs#10722:

  • Add System.Text.RegularExpressions namespace to disallow-edits.yml
  • Set open_to_public_contributors to false in the API docs repo
  • Add to the docs CI pipeline for ongoing validation

Testing

  • Build: 0 errors, 0 warnings (Release)
  • Tests: net481 (15,932 passed), net11.0 (32,068 passed)

… to source

Backport API documentation from dotnet/dotnet-api-docs into /// XML doc
comments in source, making source the single source of truth for
System.Text.RegularExpressions IntelliSense and API documentation.

This is part of the broader effort tracked in dotnet/dotnet-api-docs#10722
to migrate API docs into source code.

Changes:
- Remove UseCompilerGeneratedDocXmlFile=false from csproj, so
  compiler-generated XML becomes authoritative for IntelliSense
- Backport docs-repo content for all public types: Regex (all partials),
  Capture, Group, Match, CaptureCollection, GroupCollection,
  MatchCollection, RegexOptions, RegexCompilationInfo,
  RegexMatchTimeoutException, RegexParseError, RegexParseException,
  GeneratedRegexAttribute, ValueMatch, and delegates
- Add minimal docs for EditorBrowsable(Never) infrastructure types
  (RegexRunner, RegexRunnerFactory) to satisfy CS1591
- Convert docs-repo markdown/CDATA format to standard XML doc comments
  (<remarks>, <para>, <c>, <see>, <list>, etc.)
- Keep source-only content where docs-repo was missing (e.g. AnyNewLine,
  NonBacktracking)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.

@danmoseley danmoseley requested a review from gewarren April 16, 2026 22:53
Copy link
Copy Markdown
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

Backports richer XML documentation for System.Text.RegularExpressions APIs into source /// comments so IntelliSense and generated docs can be sourced from the runtime repo.

Changes:

  • Expanded/standardized XML doc comments across System.Text.RegularExpressions public surface area (types, members, exceptions, remarks).
  • Added XML docs for previously undocumented/protected members to avoid doc warnings (e.g., protected fields / constructors).
  • Updated project configuration by removing <UseCompilerGeneratedDocXmlFile>false</UseCompilerGeneratedDocXmlFile> so compiler-generated XML becomes authoritative.
Show a summary per file
File Description
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/ValueMatch.cs Refined XML docs for ValueMatch and its members.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexRunnerFactory.cs Added XML docs for extensibility factory type/members.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexRunner.cs Added/converted XML docs for runner APIs and helpers.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs Improved exception XML docs for parsing failures.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseError.cs Fixed/standardized enum value docs formatting.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexOptions.cs Added comprehensive option/member docs with links/remarks.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexMatchTimeoutException.cs Expanded exception docs incl. constructors/serialization/properties.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompilationInfo.cs Added docs clarifying obsolescence / source generator guidance.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs Added class/field/ctor/member docs and richer remarks.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Timeout.cs Expanded time-out related docs and remarks.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Split.cs Expanded XML docs for Split overloads.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Replace.cs Expanded XML docs for Replace overloads and MatchEvaluator.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Match.cs Expanded XML docs for IsMatch/Match/Matches overloads.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.EnumerateSplits.cs Adjusted XML docs for split enumerator APIs.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.EnumerateMatches.cs Expanded XML docs for match enumerator APIs.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Cache.cs Added docs for Regex.CacheSize and cache behavior.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/MatchCollection.cs Expanded collection docs (lazy vs direct eval, members, exceptions).
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Match.cs Replaced internal block comments with public-facing XML docs.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/GroupCollection.cs Expanded group collection docs and member documentation.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Group.cs Added richer docs for group semantics and captures.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/GeneratedRegexAttribute.cs Reflowed/standardized attribute docs and remarks.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/CaptureCollection.cs Expanded capture collection docs and member documentation.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Capture.cs Expanded capture docs (properties/remarks/ToString).
src/libraries/System.Text.RegularExpressions/src/System.Text.RegularExpressions.csproj Removed explicit opt-out of compiler-generated XML doc output.

Copilot's findings

Comments suppressed due to low confidence (4)

src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Split.cs:72

  • In XML docs, <see cref="Regex"/>.Split won’t link to the Split methods. Consider using <see cref="Regex.Split(string)"/> (or an appropriate overload) instead of linking only to the type.
        /// The <see cref="Regex"/>.Split methods are similar to the
        /// <see cref="string.Split(char[])"/> method, except that <see cref="Regex"/>.Split splits

src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Split.cs:125

  • In XML docs, <see cref="Regex"/>.Split doesn’t produce a method link. Prefer a <see cref="..."/> that targets the relevant Split overload (e.g. <see cref="Regex.Split(string)"/>) so IntelliSense links correctly.
        /// The <see cref="Regex"/>.Split methods are similar to the
        /// <see cref="string.Split(char[])"/> method, except that <see cref="Regex"/>.Split splits

src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Split.cs:163

  • These remarks use <see cref="Regex"/>.Split, which links only to the Regex type, not the Split methods. Consider switching to a specific overload like <see cref="Regex.Split(string)"/> and then referring to “this method” in text.
        /// The <see cref="Regex"/>.Split methods are similar to the
        /// <see cref="string.Split(char[])"/> method, except that <see cref="Regex"/>.Split splits

src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Split.cs:206

  • <see cref="Regex"/>.Split won’t resolve as a method link in generated docs/IntelliSense. Prefer <see cref="Regex.Split(string, int)"/> (or whatever overload is being discussed) and tweak the prose to match.
        /// The <see cref="Regex"/>.Split methods are similar to
        /// <see cref="string.Split(char[])"/>. The <paramref name="count"/> parameter specifies
  • Files reviewed: 24/24 changed files
  • Comments generated: 4

- MatchCollection.CopyTo: fix exception docs to match List<T>.CopyTo behavior
  (ArgumentOutOfRangeException for bad index, ArgumentException for multi-dim/space)
- CaptureCollection.CopyTo: fix to IndexOutOfRangeException (Array.SetValue behavior),
  add ArgumentException for multidimensional arrays
- Regex.CacheSize: change 'compiled regular expressions' to 'regular expression instances'
  since the cache stores all static Regex instances, not just Compiled ones
- Regex.Split: fix <see cref="Regex"/>.Split to <see cref="Regex.Split(string)"/>
  for proper clickable links

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add 'Gets' verb prefix to Capture.Index summary
- Remove unnecessary <description> tags from bullet list items (CaptureCollection, RegexMatchTimeoutException)
- Use <term>/<description> for definition-style list items (MatchCollection)
- Fix param description casing (CaptureCollection indexer)
- Convert relative doc links to absolute GitHub URLs (Group, Match, Regex.Match)
- Convert see-also links to <related> tags (Regex class)
- Simplify indexer self-reference in GroupCollection
- Drop '.NET Core and .NET 5+' qualifier from CompileToAssembly exceptions
- Remove redundant remarks from obsolete RegexCompilationInfo
- Move XML doc comment before #if DEBUG block to fix CS1591/CS1587

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 17, 2026 04:50
Copy link
Copy Markdown
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.

Copilot's findings

  • Files reviewed: 24/24 changed files
  • Comments generated: 2

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danmoseley danmoseley enabled auto-merge (squash) April 17, 2026 05:03
danmoseley added a commit to danmoseley/dotnet-api-docs that referenced this pull request Apr 17, 2026
The source of truth for System.Text.RegularExpressions XML docs is
being moved to dotnet/runtime (see dotnet/runtime#127038).

- Add System.Text.RegularExpressions to disallow-edits.yml GitOps policy
- Set open_to_public_contributors to false in docfx.json

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
gewarren pushed a commit to dotnet/dotnet-api-docs that referenced this pull request Apr 17, 2026
The source of truth for System.Text.RegularExpressions XML docs is
being moved to dotnet/runtime (see dotnet/runtime#127038).

- Add System.Text.RegularExpressions to disallow-edits.yml GitOps policy
- Set open_to_public_contributors to false in docfx.json

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danmoseley danmoseley merged commit 4e7eb8c into dotnet:main Apr 17, 2026
86 of 96 checks passed
@danmoseley danmoseley deleted the runtime-regex-docs branch April 17, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants