From 9210293d9e861e16a296da2cdf8cd4df30b85544 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 10 Aug 2017 09:07:53 +0200 Subject: [PATCH] dont use generic version of Marshal.SizeOf --- .../Grpc.Core.Tests/Internal/CompletionQueueEventTest.cs | 7 +++++-- src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs | 5 ++++- src/csharp/Grpc.Core/Internal/AuthContextSafeHandle.cs | 3 +-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueEventTest.cs b/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueEventTest.cs index 27c2fa8bf01..259520846f0 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueEventTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueEventTest.cs @@ -29,9 +29,12 @@ namespace Grpc.Core.Internal.Tests public class CompletionQueueEventTest { [Test] - public void CreateAndDestroy() + public void CompletionQueueEventSizeIsNativeSize() { - Assert.AreEqual(CompletionQueueEvent.NativeSize, Marshal.SizeOf()); + #pragma warning disable 0618 + // We need to use the obsolete non-generic version of Marshal.SizeOf because the generic version is not available in net45 + Assert.AreEqual(CompletionQueueEvent.NativeSize, Marshal.SizeOf(typeof(CompletionQueueEvent))); + #pragma warning restore 0618 } } } diff --git a/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs b/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs index c2ece97ba0e..be35f31c367 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs @@ -60,7 +60,10 @@ namespace Grpc.Core.Internal.Tests [Test] public void TimespecSizeIsNativeSize() { - Assert.AreEqual(Timespec.NativeSize, Marshal.SizeOf()); + #pragma warning disable 0618 + // We need to use the obsolete non-generic version of Marshal.SizeOf because the generic version is not available in net45 + Assert.AreEqual(Timespec.NativeSize, Marshal.SizeOf(typeof(Timespec))); + #pragma warning restore 0618 } [Test] diff --git a/src/csharp/Grpc.Core/Internal/AuthContextSafeHandle.cs b/src/csharp/Grpc.Core/Internal/AuthContextSafeHandle.cs index 3f5ba27c191..e8e61ebf3c8 100644 --- a/src/csharp/Grpc.Core/Internal/AuthContextSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/AuthContextSafeHandle.cs @@ -75,8 +75,7 @@ namespace Grpc.Core.Internal private AuthProperty PtrToAuthProperty(IntPtr authPropertyPtr) { #pragma warning disable 0618 - // We need to use the obsolete non-generic version of Marshal.PtrToStructure, because the generic version is not available - // in net45 on Windows. + // We need to use the obsolete non-generic version of Marshal.PtrToStructure, because the generic version is not available in net45 var nativeAuthProperty = (NativeAuthProperty) Marshal.PtrToStructure(authPropertyPtr, typeof(NativeAuthProperty)); #pragma warning restore 0618 var name = Marshal.PtrToStringAnsi(nativeAuthProperty.Name);