netstandard2.0 tweaks

pull/18351/head
Jan Tattermusch 6 years ago
parent fac3ec2563
commit cfe021a3b3
  1. 2
      src/csharp/Grpc.Core/GrpcEnvironment.cs
  2. 4
      src/csharp/Grpc.Core/Internal/NativeExtension.cs
  3. 4
      src/csharp/Grpc.Core/Internal/PlatformApis.cs
  4. 2
      src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
  5. 2
      src/csharp/Grpc.Core/Utils/TaskUtils.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

@ -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);

@ -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();

@ -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<T>(ptr); // non-generic version is obsolete
#else
return Marshal.GetDelegateForFunctionPointer(ptr, typeof(T)) as T; // generic version not available in .NET45

@ -33,7 +33,7 @@ namespace Grpc.Core.Utils
{
get
{
#if NETSTANDARD1_5
#if NETSTANDARD1_5 || NETSTANDARD2_0
return Task.CompletedTask;
#else
return Task.FromResult<object>(null); // for .NET45, emulate the functionality

Loading…
Cancel
Save