diff --git a/src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs b/src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs
index fe95c67abb779f86288e4e1f02abb46f90a336af..e758cac88d68e0268e4fe936c9faad7dfa0e3347 100644
--- a/src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs
+++ b/src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs
@@ -203,7 +203,7 @@ private static void EmitRegexDerivedTypeRunnerFactory(IndentedTextWriter writer,
$"internal static readonly TimeSpan {DefaultTimeoutFieldName} = AppContext.GetData(\"REGEX_DEFAULT_MATCH_TIMEOUT\") is TimeSpan timeout ? timeout : Regex.InfiniteMatchTimeout;",
$"",
$"/// Whether is non-infinite.",
- $"internal static readonly bool {HasDefaultTimeoutFieldName} = {DefaultTimeoutFieldName} != Timeout.InfiniteTimeSpan;",
+ $"internal static readonly bool {HasDefaultTimeoutFieldName} = {DefaultTimeoutFieldName} != Regex.InfiniteMatchTimeout;",
});
}
}
@@ -248,7 +248,7 @@ private static void EmitRegexDerivedTypeRunnerFactory(IndentedTextWriter writer,
/// Gets a C# expression representing the specified timeout value.
private static string GetTimeoutExpression(int matchTimeout) =>
matchTimeout == Timeout.Infinite ?
- "Timeout.InfiniteTimeSpan" :
+ "Regex.InfiniteMatchTimeout" :
$"TimeSpan.FromMilliseconds({matchTimeout.ToString(CultureInfo.InvariantCulture)})";
/// Adds the IsWordChar helper to the required helpers collection.