[libraries] Skip GetOpenSslVersion on Apple OS (#37646)
authorMitchell Hwang <mitchhwang1418@gmail.com>
Tue, 9 Jun 2020 17:41:46 +0000 (13:41 -0400)
committerGitHub <noreply@github.com>
Tue, 9 Jun 2020 17:41:46 +0000 (19:41 +0200)
Extend the `PlatformNotSupportedException` for `OpenSslVersion` from `OSX` to `OSX, iOS, and tvOS`, as none of these Apple OS support OpenSsl.

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>
src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs

index 38fb7d5..bb5bb4b 100644 (file)
@@ -45,12 +45,16 @@ namespace System
         public static bool IsRedHatFamily7 => IsRedHatFamilyAndVersion(7);
         public static bool IsNotFedoraOrRedHatFamily => !IsFedora && !IsRedHatFamily;
         public static bool IsNotDebian10 => !IsDebian10;
+        public static bool IsNotApple =>
+            !RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")) &&
+            !RuntimeInformation.IsOSPlatform(OSPlatform.OSX) &&
+            !RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS"));
 
         public static bool IsSuperUser => !IsWindows ?
             libc.geteuid() == 0 :
             throw new PlatformNotSupportedException();
 
-        public static Version OpenSslVersion => !IsOSX && !IsWindows ?
+        public static Version OpenSslVersion => IsNotApple && !IsWindows ?
             GetOpenSslVersion() :
             throw new PlatformNotSupportedException();