diff --git a/DiscImageChef.CommonTypes/Interop/DetectOS.cs b/DiscImageChef.CommonTypes/Interop/DetectOS.cs index 350034e24..86f2dbe5b 100644 --- a/DiscImageChef.CommonTypes/Interop/DetectOS.cs +++ b/DiscImageChef.CommonTypes/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 diff --git a/DiscImageChef.Core/Logging/DumpLog.cs b/DiscImageChef.Core/Logging/DumpLog.cs index 05df18b74..68e6d081b 100644 --- a/DiscImageChef.Core/Logging/DumpLog.cs +++ b/DiscImageChef.Core/Logging/DumpLog.cs @@ -33,6 +33,7 @@ using System; using System.IO; using System.Reflection; +using System.Runtime.InteropServices; using DiscImageChef.CommonTypes.Interop; using DiscImageChef.Devices; using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID; @@ -69,8 +70,9 @@ namespace DiscImageChef.Core.Logging logSw.WriteLine("################# System information #################"); logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer, Environment.Is64BitOperatingSystem ? 64 : 32); - if(DetectOS.IsMono) logSw.WriteLine("Mono {0}", Version.GetMonoVersion()); - else logSw.WriteLine(".NET Framework {0}", Environment.Version); + if(DetectOS.IsMono) logSw.WriteLine("Mono {0}", Version.GetMonoVersion()); + else if(DetectOS.IsNetCore) logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion()); + else logSw.WriteLine(RuntimeInformation.FrameworkDescription); logSw.WriteLine(); diff --git a/DiscImageChef.Gui/Forms/frmConsole.xeto.cs b/DiscImageChef.Gui/Forms/frmConsole.xeto.cs index 096970df9..d14510bea 100644 --- a/DiscImageChef.Gui/Forms/frmConsole.xeto.cs +++ b/DiscImageChef.Gui/Forms/frmConsole.xeto.cs @@ -34,6 +34,7 @@ using System; using System.ComponentModel; using System.IO; using System.Reflection; +using System.Runtime.InteropServices; using DiscImageChef.CommonTypes.Interop; using DiscImageChef.Console; using Eto.Drawing; @@ -142,8 +143,9 @@ namespace DiscImageChef.Gui.Forms logSw.WriteLine("################# System information #################"); logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer, Environment.Is64BitOperatingSystem ? 64 : 32); - if(DetectOS.IsMono) logSw.WriteLine("Mono {0}", Version.GetMonoVersion()); - else logSw.WriteLine(".NET Framework {0}", Environment.Version); + if(DetectOS.IsMono) logSw.WriteLine("Mono {0}", Version.GetMonoVersion()); + else if(DetectOS.IsNetCore) logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion()); + else logSw.WriteLine(RuntimeInformation.FrameworkDescription); logSw.WriteLine(); @@ -161,8 +163,7 @@ namespace DiscImageChef.Gui.Forms foreach(LogEntry entry in ConsoleHandler.Entries) if(entry.Type != "Info") logSw.WriteLine("{0}: ({1}) {2}", entry.Timestamp, entry.Type.ToLower(), entry.Message); - else - logSw.WriteLine("{0}: {1}", entry.Timestamp, entry.Message); + else logSw.WriteLine("{0}: {1}", entry.Timestamp, entry.Message); logSw.Close(); logFs.Close();