From cfe021a3b39072ea0fa58ef778fbd96a1705581f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 13 Mar 2019 11:54:13 +0100 Subject: [PATCH] netstandard2.0 tweaks --- src/csharp/Grpc.Core/GrpcEnvironment.cs | 2 +- src/csharp/Grpc.Core/Internal/NativeExtension.cs | 4 ++-- src/csharp/Grpc.Core/Internal/PlatformApis.cs | 4 ++-- src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs | 2 +- src/csharp/Grpc.Core/Utils/TaskUtils.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/csharp/Grpc.Core/GrpcEnvironment.cs b/src/csharp/Grpc.Core/GrpcEnvironment.cs index 6ca694e0e46..3c83b03cc1f 100644 --- a/src/csharp/Grpc.Core/GrpcEnvironment.cs +++ b/src/csharp/Grpc.Core/GrpcEnvironment.cs @@ -448,7 +448,7 @@ namespace Grpc.Core // the gRPC channels and servers before the application exits. The following // hooks provide some extra handling for cases when this is not the case, // in the effort to achieve a reasonable behavior on shutdown. -#if NETSTANDARD1_5 +#if NETSTANDARD1_5 || NETSTANDARD2_0 // No action required at shutdown on .NET Core // - In-progress P/Invoke calls (such as grpc_completion_queue_next) don't seem // to prevent a .NET core application from terminating, so no special handling diff --git a/src/csharp/Grpc.Core/Internal/NativeExtension.cs b/src/csharp/Grpc.Core/Internal/NativeExtension.cs index 5177b69fd90..9935ef109c8 100644 --- a/src/csharp/Grpc.Core/Internal/NativeExtension.cs +++ b/src/csharp/Grpc.Core/Internal/NativeExtension.cs @@ -153,7 +153,7 @@ namespace Grpc.Core.Internal private static string GetAssemblyPath() { var assembly = typeof(NativeExtension).GetTypeInfo().Assembly; -#if NETSTANDARD1_5 +#if NETSTANDARD1_5 || NETSTANDARD2_0 // Assembly.EscapedCodeBase does not exist under CoreCLR, but assemblies imported from a nuget package // don't seem to be shadowed by DNX-based projects at all. return assembly.Location; @@ -172,7 +172,7 @@ namespace Grpc.Core.Internal #endif } -#if !NETSTANDARD1_5 +#if !NETSTANDARD1_5 && !NETSTANDARD2_0 private static bool IsFileUri(string uri) { return uri.ToLowerInvariant().StartsWith(Uri.UriSchemeFile); diff --git a/src/csharp/Grpc.Core/Internal/PlatformApis.cs b/src/csharp/Grpc.Core/Internal/PlatformApis.cs index a8f147545b4..8d7e8c2acb5 100644 --- a/src/csharp/Grpc.Core/Internal/PlatformApis.cs +++ b/src/csharp/Grpc.Core/Internal/PlatformApis.cs @@ -49,7 +49,7 @@ namespace Grpc.Core.Internal static PlatformApis() { -#if NETSTANDARD1_5 +#if NETSTANDARD1_5 || NETSTANDARD2_0 isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux); isMacOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); @@ -171,7 +171,7 @@ namespace Grpc.Core.Internal public static string GetUnityRuntimePlatform() { GrpcPreconditions.CheckState(IsUnity, "Not running on Unity."); -#if NETSTANDARD1_5 +#if NETSTANDARD1_5 || NETSTANDARD2_0 return Type.GetType(UnityEngineApplicationClassName).GetTypeInfo().GetProperty("platform").GetValue(null).ToString(); #else return Type.GetType(UnityEngineApplicationClassName).GetProperty("platform").GetValue(null).ToString(); diff --git a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs index 1786fc2e3f6..056758df8ca 100644 --- a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs +++ b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs @@ -120,7 +120,7 @@ namespace Grpc.Core.Internal { throw new MissingMethodException(string.Format("The native method \"{0}\" does not exist", methodName)); } -#if NETSTANDARD1_5 +#if NETSTANDARD1_5 || NETSTANDARD2_0 return Marshal.GetDelegateForFunctionPointer(ptr); // non-generic version is obsolete #else return Marshal.GetDelegateForFunctionPointer(ptr, typeof(T)) as T; // generic version not available in .NET45 diff --git a/src/csharp/Grpc.Core/Utils/TaskUtils.cs b/src/csharp/Grpc.Core/Utils/TaskUtils.cs index f25106f8dd8..21cd63336dc 100644 --- a/src/csharp/Grpc.Core/Utils/TaskUtils.cs +++ b/src/csharp/Grpc.Core/Utils/TaskUtils.cs @@ -33,7 +33,7 @@ namespace Grpc.Core.Utils { get { -#if NETSTANDARD1_5 +#if NETSTANDARD1_5 || NETSTANDARD2_0 return Task.CompletedTask; #else return Task.FromResult(null); // for .NET45, emulate the functionality