Skip to content
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

Fix inconsistency in Regex infinite timeout usages #77560

Merged
merged 1 commit into from
Oct 31, 2022

Conversation

eerhardt
Copy link
Member

@eerhardt eerhardt commented Oct 27, 2022

In the Regex source generator, there is an inconsistency in which "timeout constant" we are comparing against vs. which constant we are setting when the timeout isn't specified.

Fixing it to always use Regex.InfiniteMatchTimeout.

I could have gone either way on this - there are 2 references to each in the generated code.

On one hand, if we always use Timeout.InfiniteTimeSpan and just leave Regex.InfiniteMatchTimeout as a public API for back-compat, this one unused field could be trimmed away. (an extremely minor deal)

On the other hand, if we use Timeout.InfiniteTimeSpan here, we should change all the places internally to use it as well, for consistency. Since this was a larger change, and doesn't really have that much benefit, I chose the simpler change. But I can easily be convinced the other way as well.

In the Regex source generator, there is an inconsistency in which "timeout constant" we are comparing against vs. which constant we are setting when the timeout isn't specified.

Fixing it to always use Regex.InfiniteMatchTimeout.
@ghost
Copy link

ghost commented Oct 27, 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

In the Regex source generator, there is an inconsistency in which "timeout constant" we are comparing against vs. which constant we are setting when the timeout isn't specified.

Fixing it to always use Regex.InfiniteMatchTimeout.

I could have gone either way on this - there are 2 references to each in the generated code.

On one hand, if we always use Timeout.InfiniteTimeSpan and just leave Regex.InfiniteMatchTimeout as a public API for back-compat, this one unused field could be trimmed away. (not a big deal)

On the other hand, if we use Timeout.InfiniteTimeSpan here, we should change all the places internally to use it as well, for consistency. Since this was a larger change, and doesn't really have that much benefit, I chose the simpler change. But I can easily be convinced the other way as well.

Author: eerhardt
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: -

@eerhardt eerhardt merged commit 30d8593 into dotnet:main Oct 31, 2022
@eerhardt eerhardt deleted the UseRegexInfiniteTimeout branch October 31, 2022 15:42
@ghost ghost locked as resolved and limited conversation to collaborators Nov 30, 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.

3 participants