Skip to content

Fix Regex.EnumerateMatches(span, pattern, options) always throwing - #647

Merged
SimonCropp merged 1 commit into
mainfrom
fix/regex-enumeratematches-timeout
Oct 11, 2026
Merged

SimonCropp merged 1 commit into
mainfrom
fix/regex-enumeratematches-timeout

Conversation

@SimonCropp

Copy link
Copy Markdown
Owner

Bug

Below net7.0 the static polyfill Regex.EnumerateMatches(ReadOnlySpan<char>, string, RegexOptions) passed TimeSpan.MaxValue as the match timeout. Regex rejects that value, so every call threw ArgumentOutOfRangeException.

Fix

Pass Regex.InfiniteMatchTimeout, the value that means "no timeout".

Test

EnumerateMatchesStatic_WithOptions in PolyfillTests_Regex.cs calls the overload with RegexOptions.IgnoreCase and asserts the matches found. It threw ArgumentOutOfRangeException on net48 before the fix and passes on net48 and net6.0 (polyfill) and net10.0 (BCL) after it. EnumerateMatchesStatic_WithOptionsAndTimeout adds the same coverage for the neighbouring timeout overload, which had none.

@SimonCropp SimonCropp added this to the 11.4.4 milestone Oct 11, 2026
@SimonCropp
SimonCropp merged commit a23092d into main Oct 11, 2026
5 checks passed
@SimonCropp
SimonCropp deleted the fix/regex-enumeratematches-timeout branch October 11, 2026 22:11
This was referenced Oct 12, 2026
This was referenced Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant