Merge pull request #24485 from gitfool/gh24153

Fix to not require libc-dev on .NET 5 or later
pull/24566/head
Jan Tattermusch 4 years ago committed by GitHub
commit 7fccdd7385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs
  2. 2
      src/csharp/Grpc.Core/GrpcEnvironment.cs
  3. 4
      src/csharp/Grpc.Core/Internal/NativeExtension.cs
  4. 10
      src/csharp/Grpc.Core/Internal/PlatformApis.cs
  5. 2
      src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
  6. 2
      src/csharp/Grpc.Core/Utils/TaskUtils.cs

@ -101,7 +101,7 @@ namespace Grpc.Auth
/// </summary> /// </summary>
private static Task GetCompletedTask() private static Task GetCompletedTask()
{ {
#if NETSTANDARD1_5 || NETSTANDARD2_0 #if NETSTANDARD
return Task.CompletedTask; return Task.CompletedTask;
#else #else
return Task.FromResult<object>(null); // for .NET45, emulate the functionality return Task.FromResult<object>(null); // for .NET45, emulate the functionality

@ -448,7 +448,7 @@ namespace Grpc.Core
// the gRPC channels and servers before the application exits. The following // the gRPC channels and servers before the application exits. The following
// hooks provide some extra handling for cases when this is not the case, // hooks provide some extra handling for cases when this is not the case,
// in the effort to achieve a reasonable behavior on shutdown. // in the effort to achieve a reasonable behavior on shutdown.
#if NETSTANDARD1_5 || NETSTANDARD2_0 #if NETSTANDARD
// No action required at shutdown on .NET Core // No action required at shutdown on .NET Core
// - In-progress P/Invoke calls (such as grpc_completion_queue_next) don't seem // - 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 // to prevent a .NET core application from terminating, so no special handling

@ -156,7 +156,7 @@ namespace Grpc.Core.Internal
private static string GetAssemblyPath() private static string GetAssemblyPath()
{ {
var assembly = typeof(NativeExtension).GetTypeInfo().Assembly; var assembly = typeof(NativeExtension).GetTypeInfo().Assembly;
#if NETSTANDARD1_5 || NETSTANDARD2_0 #if NETSTANDARD
// Assembly.EscapedCodeBase does not exist under CoreCLR, but assemblies imported from a nuget package // 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. // don't seem to be shadowed by DNX-based projects at all.
return assembly.Location; return assembly.Location;
@ -175,7 +175,7 @@ namespace Grpc.Core.Internal
#endif #endif
} }
#if !NETSTANDARD1_5 && !NETSTANDARD2_0 #if !NETSTANDARD
private static bool IsFileUri(string uri) private static bool IsFileUri(string uri)
{ {
return uri.ToLowerInvariant().StartsWith(Uri.UriSchemeFile); return uri.ToLowerInvariant().StartsWith(Uri.UriSchemeFile);

@ -49,11 +49,15 @@ namespace Grpc.Core.Internal
static PlatformApis() static PlatformApis()
{ {
#if NETSTANDARD1_5 || NETSTANDARD2_0 #if NETSTANDARD
isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux); isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
isMacOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); isMacOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
isNetCore = RuntimeInformation.FrameworkDescription.StartsWith(".NET Core"); isNetCore =
#if NETSTANDARD2_0
Environment.Version.Major >= 5 ||
#endif
RuntimeInformation.FrameworkDescription.StartsWith(".NET Core");
#else #else
var platform = Environment.OSVersion.Platform; var platform = Environment.OSVersion.Platform;
@ -171,7 +175,7 @@ namespace Grpc.Core.Internal
public static string GetUnityRuntimePlatform() public static string GetUnityRuntimePlatform()
{ {
GrpcPreconditions.CheckState(IsUnity, "Not running on Unity."); GrpcPreconditions.CheckState(IsUnity, "Not running on Unity.");
#if NETSTANDARD1_5 || NETSTANDARD2_0 #if NETSTANDARD
return Type.GetType(UnityEngineApplicationClassName).GetTypeInfo().GetProperty("platform").GetValue(null).ToString(); return Type.GetType(UnityEngineApplicationClassName).GetTypeInfo().GetProperty("platform").GetValue(null).ToString();
#else #else
return Type.GetType(UnityEngineApplicationClassName).GetProperty("platform").GetValue(null).ToString(); 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)); throw new MissingMethodException(string.Format("The native method \"{0}\" does not exist", methodName));
} }
#if NETSTANDARD1_5 || NETSTANDARD2_0 #if NETSTANDARD
return Marshal.GetDelegateForFunctionPointer<T>(ptr); // non-generic version is obsolete return Marshal.GetDelegateForFunctionPointer<T>(ptr); // non-generic version is obsolete
#else #else
return Marshal.GetDelegateForFunctionPointer(ptr, typeof(T)) as T; // generic version not available in .NET45 return Marshal.GetDelegateForFunctionPointer(ptr, typeof(T)) as T; // generic version not available in .NET45

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

Loading…
Cancel
Save