From 0b907fc9d1cc37a69ab7877567154be8ab757e7f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 23 Jul 2018 19:13:41 +0200 Subject: improve xamarin platform detection --- src/csharp/Grpc.Core/Internal/PlatformApis.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/csharp/Grpc.Core/Internal/PlatformApis.cs b/src/csharp/Grpc.Core/Internal/PlatformApis.cs index 6c4ee0bdb7..c501aa89fb 100644 --- a/src/csharp/Grpc.Core/Internal/PlatformApis.cs +++ b/src/csharp/Grpc.Core/Internal/PlatformApis.cs @@ -33,8 +33,9 @@ namespace Grpc.Core.Internal internal static class PlatformApis { const string UnityEngineApplicationClassName = "UnityEngine.Application, UnityEngine"; - const string XamarinAndroidActivityClassName = "Android.App.Activity, Mono.Android"; - const string XamariniOSEnumClassName = "Mono.CSharp.Enum, Mono.CSharp"; + const string XamarinAndroidObjectClassName = "Java.Lang.Object, Mono.Android"; + const string XamarinIOSObjectClassName = "Foundation.NSObject, Xamarin.iOS"; + static readonly bool isLinux; static readonly bool isMacOSX; static readonly bool isWindows; @@ -42,7 +43,7 @@ namespace Grpc.Core.Internal static readonly bool isNetCore; static readonly bool isUnity; static readonly bool isXamarin; - static readonly bool isXamariniOS; + static readonly bool isXamarinIOS; static readonly bool isXamarinAndroid; static PlatformApis() @@ -63,9 +64,9 @@ namespace Grpc.Core.Internal #endif isMono = Type.GetType("Mono.Runtime") != null; isUnity = Type.GetType(UnityEngineApplicationClassName) != null; - isXamariniOS = Type.GetType(XamariniOSEnumClassName) != null; - isXamarinAndroid = Type.GetType(XamarinAndroidActivityClassName) != null; - isXamarin = isXamariniOS || isXamarinAndroid; + isXamarinIOS = Type.GetType(XamarinIOSObjectClassName) != null; + isXamarinAndroid = Type.GetType(XamarinAndroidObjectClassName) != null; + isXamarin = isXamarinIOS || isXamarinAndroid; } public static bool IsLinux @@ -108,9 +109,9 @@ namespace Grpc.Core.Internal /// /// true if running on Xamarin.iOS, false otherwise. /// - public static bool IsXamariniOS + public static bool IsXamarinIOS { - get { return isXamariniOS; } + get { return isXamarinIOS; } } /// -- cgit v1.2.3