aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Core.Tests/PInvokeTest.cs
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2016-01-12 17:57:25 -0800
committerGravatar Jan Tattermusch <jtattermusch@google.com>2016-01-15 15:21:13 -0800
commitafab541d01852aa086adfbf589be776a39c2aa3f (patch)
treeca0f6a2f7667ca034296586abe3c4b517dc0a0f9 /src/csharp/Grpc.Core.Tests/PInvokeTest.cs
parent623ca7dd9408fea1b6e88be0ca1e0f845a0533e8 (diff)
revamp C# native library loader
Diffstat (limited to 'src/csharp/Grpc.Core.Tests/PInvokeTest.cs')
-rw-r--r--src/csharp/Grpc.Core.Tests/PInvokeTest.cs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/csharp/Grpc.Core.Tests/PInvokeTest.cs b/src/csharp/Grpc.Core.Tests/PInvokeTest.cs
index af55cb0566..ea6572e7c0 100644
--- a/src/csharp/Grpc.Core.Tests/PInvokeTest.cs
+++ b/src/csharp/Grpc.Core.Tests/PInvokeTest.cs
@@ -45,13 +45,9 @@ namespace Grpc.Core.Tests
{
public class PInvokeTest
{
- int counter;
-
- [DllImport("grpc_csharp_ext.dll")]
- static extern GRPCCallError grpcsharp_test_callback([MarshalAs(UnmanagedType.FunctionPtr)] OpCompletionDelegate callback);
+ static readonly NativeMethods Native = NativeMethods.Get();
- [DllImport("grpc_csharp_ext.dll")]
- static extern IntPtr grpcsharp_test_nop(IntPtr ptr);
+ int counter;
/// <summary>
/// (~1.26us .NET Windows)
@@ -87,7 +83,7 @@ namespace Grpc.Core.Tests
1000000, 10000000,
() =>
{
- grpcsharp_test_callback(handler);
+ Native.grpcsharp_test_callback(handler);
});
Assert.AreNotEqual(0, counter);
}
@@ -106,7 +102,7 @@ namespace Grpc.Core.Tests
10000, 10000,
() =>
{
- grpcsharp_test_callback(new OpCompletionDelegate(Handler));
+ Native.grpcsharp_test_callback(new OpCompletionDelegate(Handler));
});
Assert.AreNotEqual(0, counter);
}
@@ -122,7 +118,7 @@ namespace Grpc.Core.Tests
1000000, 100000000,
() =>
{
- grpcsharp_test_nop(IntPtr.Zero);
+ Native.grpcsharp_test_nop(IntPtr.Zero);
});
}