未验证 提交 30d85939 编写于 作者: E Eric Erhardt 提交者: GitHub

Fix inconsistency in Regex infinite timeout usages (#77560)

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.
上级 22ecd7e0
......@@ -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;",
$"",
$"/// <summary>Whether <see cref=\"{DefaultTimeoutFieldName}\"/> is non-infinite.</summary>",
$"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,
/// <summary>Gets a C# expression representing the specified timeout value.</summary>
private static string GetTimeoutExpression(int matchTimeout) =>
matchTimeout == Timeout.Infinite ?
"Timeout.InfiniteTimeSpan" :
"Regex.InfiniteMatchTimeout" :
$"TimeSpan.FromMilliseconds({matchTimeout.ToString(CultureInfo.InvariantCulture)})";
/// <summary>Adds the IsWordChar helper to the required helpers collection.</summary>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册