From f0adf40189d5a3319c50f027f7241fd5ac32eee6 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 10 Apr 2022 10:17:05 +0100 Subject: [PATCH] Add support for detecting macOS 11 and 12. --- Interop/DetectOS.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Interop/DetectOS.cs b/Interop/DetectOS.cs index a0f28a51f..cff4216c5 100644 --- a/Interop/DetectOS.cs +++ b/Interop/DetectOS.cs @@ -79,7 +79,7 @@ public static class DetectOS { get { - if(!IsWindows) + if(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return Environment.UserName == "root"; bool isAdmin; @@ -223,6 +223,9 @@ public static class DetectOS switch(GetRealPlatformID()) { case PlatformID.MacOSX: + if(Environment.OSVersion.Version.Major >= 11) + return environ; + if(Environment.OSVersion.Version.Major != 1) return $"10.{Environment.OSVersion.Version.Major - 4}.{Environment.OSVersion.Version.Minor}"; @@ -281,13 +284,13 @@ public static class DetectOS !int.TryParse(pieces[1], out int minor)) return "macOS"; - if(minor >= 12) + int.TryParse(pieces[0], out int major); + + if(minor >= 12 || + major >= 11) return "macOS"; - if(minor >= 8) - return "OS X"; - - return "Mac OS X"; + return minor >= 8 ? "OS X" : "Mac OS X"; case PlatformID.Minix: return "MINIX"; case PlatformID.NetBSD: return "NetBSD";