From 46464bd651568673cbb82717c4d3bbe558595ef3 Mon Sep 17 00:00:00 2001 From: Dan Moseley Date: Sat, 23 Apr 2022 18:27:47 -0600 Subject: [PATCH] Make PlatformDetection.IsInHelix lazy (#68445) * Make IsInHelix lazy * Update src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> --- .../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..f92ec2a8c0bb2 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().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); public static bool IsMonoRuntime => Type.GetType("Mono.RuntimeStructs") != null;