diff --git a/Interop/DetectOS.cs b/Interop/DetectOS.cs index 350034e24..86f2dbe5b 100644 --- a/Interop/DetectOS.cs +++ b/Interop/DetectOS.cs @@ -46,7 +46,14 @@ namespace DiscImageChef.CommonTypes.Interop { public static class DetectOS { - public static readonly bool IsMono = Type.GetType("Mono.Runtime") != null; + public static readonly bool IsMono = + RuntimeInformation.FrameworkDescription.StartsWith("Mono", StringComparison.Ordinal); + public static readonly bool IsNetFramework = + RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal); + public static readonly bool IsNetCore = + RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.Ordinal); + public static readonly bool IsNetNative = + RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal); /// /// Checks if the underlying runtime runs in 64-bit mode @@ -115,6 +122,7 @@ namespace DiscImageChef.CommonTypes.Interop return PlatformID.Linux; #endif } + case "Darwin": { IntPtr pLen = Marshal.AllocHGlobal(sizeof(int)); @@ -149,6 +157,7 @@ namespace DiscImageChef.CommonTypes.Interop return PlatformID.MacOSX; } + case "GNU": return PlatformID.Hurd; case "FreeBSD": case "GNU/kFreeBSD": return PlatformID.FreeBSD; @@ -308,27 +317,27 @@ namespace DiscImageChef.CommonTypes.Interop /// System name /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string sysname; + public readonly string sysname; /// /// Node name /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string nodename; + public readonly string nodename; /// /// Release level /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string release; + public readonly string release; /// /// Version level /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string version; + public readonly string version; /// /// Hardware level /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string machine; + public readonly string machine; } } } \ No newline at end of file