From f59250315b9b99b00169f4f830c2ff29dfa13009 Mon Sep 17 00:00:00 2001 From: Dan Moseley Date: Sat, 23 Apr 2022 11:37:40 -0600 Subject: [PATCH 1/2] Make IsInHelix lazy --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 87e064b2ec413..08d2a6929c8dd 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -23,7 +23,8 @@ public static partial class PlatformDetection // do it in a way that failures don't cascade. // - public static readonly bool IsInHelix = Environment.GetEnvironmentVariables().Keys.Cast().Where(key => key.StartsWith("HELIX")).Any(); + private static Lazy s_IsInHelix => new Lazy(() => Environment.GetEnvironmentVariables().Keys.Cast().Where(key => key.StartsWith("HELIX")).Any()); + public static bool IsInHelix => s_IsInHelix.Value; public static bool IsNetCore => Environment.Version.Major >= 5 || RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase); public static bool IsMonoRuntime => Type.GetType("Mono.RuntimeStructs") != null; From 1a412199999bb224e47a5ff356d7d3173042ab0b Mon Sep 17 00:00:00 2001 From: Dan Moseley Date: Sat, 23 Apr 2022 12:51:15 -0600 Subject: [PATCH 2/2] Update src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 08d2a6929c8dd..f92ec2a8c0bb2 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -23,7 +23,7 @@ public static partial class PlatformDetection // do it in a way that failures don't cascade. // - private static Lazy s_IsInHelix => new Lazy(() => Environment.GetEnvironmentVariables().Keys.Cast().Where(key => key.StartsWith("HELIX")).Any()); + private static Lazy s_IsInHelix => new Lazy(() => Environment.GetEnvironmentVariables().Keys.Cast().Any(key => key.StartsWith("HELIX"))); public static bool IsInHelix => s_IsInHelix.Value; public static bool IsNetCore => Environment.Version.Major >= 5 || RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase);