Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix regex description emitted by generator for switched branches #115136

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stephentoub
Copy link
Member

The emitter is mutating the regex tree, under the assumption that no one subsequently looks at the tree... but the XML comment generator does. Make sure the mutations are undone.

Fixes #114889

The emitter is mutating the regex tree, under the assumption that no one subsequently looks at the tree... but the XML comment generator does. Make sure the mutations are undone.
@Copilot Copilot AI review requested due to automatic review settings April 29, 2025 00:01
Copy link
Contributor

@Copilot 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

A concise update to fix the regex description emitted by the generator for switched branches by ensuring that temporary mutations to the regex tree are undone properly.

  • Updated the GeneratedCodeAttribute version placeholder in test output.
  • Modified the emitter logic to correctly slice off the first character for multi and concatenation nodes, including restoring the original state after mutation.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexGeneratorOutputTests.cs Updated test output to use a version placeholder and add new test cases verifying the generator’s output.
src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs Modified the code emission for switched branches to correctly slice off the first character and safely restore mutated nodes.

Copy link
Contributor

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

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.

Wrong summary for generated regex
1 participant