Closed
Description
Description
[GeneratedRegex(@"\b(ifn?def|endif)?")]
private static partial Regex MyRegex1 { get; }
The summary generated should state it matches the string if
before the optional n
, but instead it states Match an empty string.
:
I examined the generated matching code and it did look for the 'i' then the 'f', so it appears only the summary was wrong.
Reproduction Steps
[GeneratedRegex(@"\b(ifn?def|endif)?")]
private static partial Regex MyRegex1 { get; }
Expected behavior
summary should be stated correctly
Actual behavior
summary was wrong
Regression?
No response
Known Workarounds
Don't look at it?
Configuration
VS 17.13.6
.NET 9
Other information
No response
Activity
dotnet-policy-service commentedon Apr 22, 2025
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.
steveharter commentedon Apr 25, 2025
@pawchen can you please open an issue here: https://developercommunity.visualstudio.com/VisualStudio?q=regex
pawchen commentedon Apr 25, 2025
@steveharter I believe the source code for the generated summary is in this repo.
huoyaoyuan commentedon Apr 28, 2025
Yes, the summary is generated by the Regex source generator. /cc @stephentoub
stephentoub commentedon Apr 28, 2025
The problem is here:
runtime/src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs
Lines 1839 to 1849 in 29e3af6
The emitter is mutating the regex node tree, for convenience and under the assumption that after this point no one else will be looking at the tree. But the XML comment generator does.