dont use generic version of Marshal.SizeOf

pull/12127/head
Jan Tattermusch 7 years ago
parent 271cb36f56
commit 9210293d9e
  1. 7
      src/csharp/Grpc.Core.Tests/Internal/CompletionQueueEventTest.cs
  2. 5
      src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs
  3. 3
      src/csharp/Grpc.Core/Internal/AuthContextSafeHandle.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<CompletionQueueEvent>());
#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
}
}
}

@ -60,7 +60,10 @@ namespace Grpc.Core.Internal.Tests
[Test]
public void TimespecSizeIsNativeSize()
{
Assert.AreEqual(Timespec.NativeSize, Marshal.SizeOf<Timespec>());
#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]

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

Loading…
Cancel
Save