Skip to content

Conversation

@stephentoub
Copy link
Member

Code coverage revealed some gaps in testing around conditionals, which in turn led to discovering a) some bugs in both RegexCompiler and the source generator around expression conditionals, and b) divergence between the compiler and the source generator. This adds tests to address the code coverage gaps and fixes the implementations to both address the bugs and bring the code much closer. The main problem with expressional conditionals was flawed handling of backtracking, either not pushing the right state on to the stack or not initializing the state correctly in the first place.

@ghost
Copy link

ghost commented Jan 6, 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

Code coverage revealed some gaps in testing around conditionals, which in turn led to discovering a) some bugs in both RegexCompiler and the source generator around expression conditionals, and b) divergence between the compiler and the source generator. This adds tests to address the code coverage gaps and fixes the implementations to both address the bugs and bring the code much closer. The main problem with expressional conditionals was flawed handling of backtracking, either not pushing the right state on to the stack or not initializing the state correctly in the first place.

Author: stephentoub
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: 7.0.0

@ghost ghost assigned stephentoub Jan 6, 2022
@danmoseley
Copy link
Member

Seems reasonable to me but probably best @joperezr reviews it more carefully.

Code coverage revealed some gaps in testing around conditionals, which in turn led to discovering a) some bugs in both RegexCompiler and the source generator around expression conditionals, and b) divergence between the compiler and the source generator.  This adds tests to address the code coverage gaps and fixes the implementations to both address the bugs and bring the code much closer.  The main problem with expressional conditionals was flawed handling of backtracking, either not pushing the right state on to the stack or not initializing the state correctly in the first place.  We also failed to revert positional changes made in the expression condition when the condition failed to match.
@stephentoub
Copy link
Member Author

@danmoseley, I pushed changes that ensure every conditional has both a yes and a no branch, so that every engine will consistently see both and we'll minimize potential divergence. Please take another look. Thanks.

@danmoseley
Copy link
Member

GetDescriptor_GetWhenNull_ThrowsNullReferenceException failure is #63482 (comment)

@stephentoub
Copy link
Member Author

macOS failures are #63561

@stephentoub stephentoub merged commit 9d5cfc5 into dotnet:main Jan 10, 2022
@stephentoub stephentoub deleted the fixregexconditionals branch January 10, 2022 17:20
@ghost ghost locked as resolved and limited conversation to collaborators Feb 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants