Skip to content

Conversation

@pedrobsaila
Copy link
Contributor

Fixes #62715

@ghost ghost added area-System.Text.RegularExpressions community-contribution Indicates that the PR has been added by a community member labels Jan 1, 2022
@ghost
Copy link

ghost commented Jan 1, 2022

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

Issue Details

Fixes #62715

Author: pedrobsaila
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: -

@GSPP
Copy link

GSPP commented Jan 2, 2022

Can capture group names contain newline characters? That could break the code that's emitted.

@pedrobsaila
Copy link
Contributor Author

pedrobsaila commented Jan 2, 2022

Can capture group names contain newline characters? That could break the code that's emitted.

Newline characters are not valid inside group name. If you try it inside a console app, you will get a RegexParseException with message : "Invalid pattern '[regex]' Invalid group name: Group names must begin with a word character."

@danmoseley
Copy link
Member

Newline characters are not valid inside group name. If you try it inside a console app, you will get a RegexParseException with message : "Invalid pattern '[regex]' Invalid group name: Group names must begin with a word character."

That message is wrong, it should say "Invalid pattern '[regex]' Invalid group name: Group names must only contain word characters.".

pedrobsaila and others added 2 commits January 11, 2022 07:10
- Pass correct arguments into GroupNameFromNumber from RegexCode
- Use capture group name for backreferences and backreference conditionals as well
- Only render the group number if there is no name
- Consistenly use the "capture group" suffix
- Clean up GroupNameFromNumber to avoid duplicate string.Empty fallback cases
- Fixes rendering of balancing groups
@stephentoub
Copy link
Member

Thanks, @pedrobsaila. I rebased your branch and pushed a commit to fix up a few things. Should be good to go once CI passes.

@stephentoub stephentoub merged commit bd9f1c4 into dotnet:main Jan 11, 2022
@pedrobsaila pedrobsaila deleted the 62715 branch January 25, 2022 22:53
@ghost ghost locked as resolved and limited conversation to collaborators Feb 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Text.RegularExpressions community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regex source generator should include capture group name in comment

4 participants