Support coreclr platform detection

Coreclr uses different platform detection primitives to full .NET
pull/5086/head
Chris Bacon 9 years ago
parent f6c7951e44
commit c65ceefbe0
  1. 6
      src/csharp/Grpc.Core/Internal/PlatformApis.cs

@ -53,12 +53,18 @@ namespace Grpc.Core.Internal
static PlatformApis()
{
#if DNXCORE50
isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
isMacOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#else
var platform = Environment.OSVersion.Platform;
// PlatformID.MacOSX is never returned, commonly used trick is to identify Mac is by using uname.
isMacOSX = (platform == PlatformID.Unix && GetUname() == "Darwin");
isLinux = (platform == PlatformID.Unix && !isMacOSX);
isWindows = (platform == PlatformID.Win32NT || platform == PlatformID.Win32S || platform == PlatformID.Win32Windows);
#endif
isMono = Type.GetType("Mono.Runtime") != null;
}

Loading…
Cancel
Save