diff options
author | Jan Tattermusch <jtattermusch@google.com> | 2018-03-07 21:49:23 +0100 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@google.com> | 2018-03-07 21:49:23 +0100 |
commit | 660547dc04961f91111c9a6cb2a4f3d6b0424aa6 (patch) | |
tree | 0d7db2be773557a36b506e2d3c678a9a2fb63d0c /src | |
parent | dcf340e8c97bc8efb3536132f3e3938dae6702c8 (diff) |
fix build on netstandard1.5
Diffstat (limited to 'src')
-rw-r--r-- | src/csharp/Grpc.Core/Internal/PlatformApis.cs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/csharp/Grpc.Core/Internal/PlatformApis.cs b/src/csharp/Grpc.Core/Internal/PlatformApis.cs index ce99ba4d77..b90fbccb2b 100644 --- a/src/csharp/Grpc.Core/Internal/PlatformApis.cs +++ b/src/csharp/Grpc.Core/Internal/PlatformApis.cs @@ -32,6 +32,7 @@ namespace Grpc.Core.Internal /// </summary> internal static class PlatformApis { + const string UnityEngineApplicationClassName = "UnityEngine.Application, UnityEngine"; static readonly bool isLinux; static readonly bool isMacOSX; static readonly bool isWindows; @@ -56,7 +57,7 @@ namespace Grpc.Core.Internal isNetCore = false; #endif isMono = Type.GetType("Mono.Runtime") != null; - isUnity = Type.GetType("UnityEngine.Application, UnityEngine") != null; + isUnity = Type.GetType(UnityEngineApplicationClassName) != null; } public static bool IsLinux @@ -109,7 +110,11 @@ namespace Grpc.Core.Internal public static string GetUnityRuntimePlatform() { GrpcPreconditions.CheckState(IsUnity, "Not running on Unity."); - return Type.GetType("UnityEngine.Application, UnityEngine").GetProperty("platform").GetValue(null).ToString(); +#if NETSTANDARD1_5 + return Type.GetType(UnityEngineApplicationClassName).GetTypeInfo().GetProperty("platform").GetValue(null).ToString(); +#else + return Type.GetType(UnityEngineApplicationClassName).GetProperty("platform").GetValue(null).ToString(); +#endif } [DllImport("libc")] |