Skip to content

Commit 46464bd

Browse files
danmoseleyam11
andauthored
Make PlatformDetection.IsInHelix lazy (#68445)
* Make IsInHelix lazy * Update src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs Co-authored-by: Adeel Mujahid <[email protected]> Co-authored-by: Adeel Mujahid <[email protected]>
1 parent 4fe6359 commit 46464bd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public static partial class PlatformDetection
2323
// do it in a way that failures don't cascade.
2424
//
2525

26-
public static readonly bool IsInHelix = Environment.GetEnvironmentVariables().Keys.Cast<string>().Where(key => key.StartsWith("HELIX")).Any();
26+
private static Lazy<bool> s_IsInHelix => new Lazy<bool>(() => Environment.GetEnvironmentVariables().Keys.Cast<string>().Any(key => key.StartsWith("HELIX")));
27+
public static bool IsInHelix => s_IsInHelix.Value;
2728

2829
public static bool IsNetCore => Environment.Version.Major >= 5 || RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase);
2930
public static bool IsMonoRuntime => Type.GetType("Mono.RuntimeStructs") != null;

0 commit comments

Comments
 (0)