From 9e168b2b815076f3e1b682ca5a7458582ce16c5d Mon Sep 17 00:00:00 2001 From: mokarchi Date: Fri, 23 Feb 2024 00:08:40 +0330 Subject: [PATCH 1/2] Add regex evaluation timeout --- src/xunit.runner.visualstudio/Utility/RunSettings.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/xunit.runner.visualstudio/Utility/RunSettings.cs b/src/xunit.runner.visualstudio/Utility/RunSettings.cs index 7776396..12f33f5 100644 --- a/src/xunit.runner.visualstudio/Utility/RunSettings.cs +++ b/src/xunit.runner.visualstudio/Utility/RunSettings.cs @@ -233,7 +233,9 @@ public bool IsMatchingTargetFramework() } // This should match .NET versions like 'net6.0' but not .NET Framework version like 'net462'. - static readonly Regex regexNet5Plus = new(@"^net\d+\.\d+$"); + private static readonly RegexOptions RegexOptions = + RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.IgnoreCase; + static readonly Regex regexNet5Plus = new(@"^net\d+\.\d+$", RegexOptions, TimeSpan.FromSeconds(1)); static bool IsNetCore(string targetFrameworkVersion) => targetFrameworkVersion.StartsWith(".NETCoreApp,", StringComparison.OrdinalIgnoreCase) || From 889cc8706ae2956c0f5f7a5db27622c0415fda66 Mon Sep 17 00:00:00 2001 From: Brad Wilson Date: Thu, 22 Feb 2024 15:16:12 -0800 Subject: [PATCH 2/2] Coding style --- src/xunit.runner.visualstudio/Utility/RunSettings.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/xunit.runner.visualstudio/Utility/RunSettings.cs b/src/xunit.runner.visualstudio/Utility/RunSettings.cs index 12f33f5..2e3593f 100644 --- a/src/xunit.runner.visualstudio/Utility/RunSettings.cs +++ b/src/xunit.runner.visualstudio/Utility/RunSettings.cs @@ -233,9 +233,7 @@ public bool IsMatchingTargetFramework() } // This should match .NET versions like 'net6.0' but not .NET Framework version like 'net462'. - private static readonly RegexOptions RegexOptions = - RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.IgnoreCase; - static readonly Regex regexNet5Plus = new(@"^net\d+\.\d+$", RegexOptions, TimeSpan.FromSeconds(1)); + static readonly Regex regexNet5Plus = new(@"^net\d+\.\d+$", RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.IgnoreCase, TimeSpan.FromSeconds(1)); static bool IsNetCore(string targetFrameworkVersion) => targetFrameworkVersion.StartsWith(".NETCoreApp,", StringComparison.OrdinalIgnoreCase) ||