/
RuntimeInformation.Unix.cs
44 lines (36 loc) · 1.24 KB
/
RuntimeInformation.Unix.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
namespace System.Runtime.InteropServices
{
public static partial class RuntimeInformation
{
private static string? s_osDescription;
private static volatile int s_osArchPlusOne;
public static string OSDescription => s_osDescription ??= (GetPrettyOSDescription() ?? Interop.Sys.GetUnixVersion());
public static Architecture OSArchitecture
{
get
{
int osArch = s_osArchPlusOne - 1;
if (osArch < 0)
{
osArch = Interop.Sys.GetOSArchitecture();
if (osArch < 0)
osArch = (int)ProcessArchitecture;
s_osArchPlusOne = osArch + 1;
}
Debug.Assert(osArch >= 0);
return (Architecture)osArch;
}
}
private static string? GetPrettyOSDescription()
{
if (OperatingSystem.IsLinux())
{
return Interop.OSReleaseFile.GetPrettyName();
}
return null;
}
}
}