Skip to content

Commit

Permalink
Make PlatformDetection.IsInHelix lazy (#68445)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
danmoseley and am11 authored Apr 24, 2022
1 parent 4fe6359 commit 46464bd
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>().Where(key => key.StartsWith("HELIX")).Any();
private static Lazy<bool> s_IsInHelix => new Lazy<bool>(() => Environment.GetEnvironmentVariables().Keys.Cast<string>().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;
Expand Down

0 comments on commit 46464bd

Please sign in to comment.