aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2018-07-23 19:15:48 +0200
committerGravatar GitHub <noreply@github.com>2018-07-23 19:15:48 +0200
commit53d2899374e74b4185a55e3fc26b64d0a02840a8 (patch)
tree9cc30a8b2ade1c4e6cb9cd63ba12a24dad271f4c
parent5c103c4d0c374b020c3dff0a71490f96f89b116c (diff)
parentbf5524b1c1920242e7b04aedf466da580733c864 (diff)
Merge pull request #16094 from jtattermusch/mark_native_callbacks
Mark native callbacks with MonoPInvokeCallback
-rw-r--r--src/csharp/Grpc.Core/Internal/NativeLogRedirector.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/csharp/Grpc.Core/Internal/NativeLogRedirector.cs b/src/csharp/Grpc.Core/Internal/NativeLogRedirector.cs
index bf6440123a..30264acb10 100644
--- a/src/csharp/Grpc.Core/Internal/NativeLogRedirector.cs
+++ b/src/csharp/Grpc.Core/Internal/NativeLogRedirector.cs
@@ -51,6 +51,7 @@ namespace Grpc.Core.Internal
}
}
+ [MonoPInvokeCallback(typeof(GprLogDelegate))]
private static void HandleWrite(IntPtr fileStringPtr, int line, ulong threadId, IntPtr severityStringPtr, IntPtr msgPtr)
{
try
@@ -86,4 +87,22 @@ namespace Grpc.Core.Internal
}
}
}
+
+ /// <summary>
+ /// Use this attribute to mark methods that will be called back from P/Invoke calls.
+ /// iOS (and probably other AOT platforms) needs to have delegates registered.
+ /// Instead of depending on Xamarin.iOS for this, we can just create our own,
+ /// the iOS runtime just checks for the type name.
+ /// See: https://docs.microsoft.com/en-gb/xamarin/ios/internals/limitations#reverse-callbacks
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Method)]
+ internal sealed class MonoPInvokeCallbackAttribute : Attribute
+ {
+ public MonoPInvokeCallbackAttribute(Type type)
+ {
+ Type = type;
+ }
+
+ public Type Type { get; private set; }
+ }
}