diff options
author | Matthew Leibowitz <mattleibow@live.com> | 2018-07-21 19:40:19 +0200 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@google.com> | 2018-07-23 17:53:20 +0200 |
commit | 1add55dbda076393bea0419b707f3353235d05ff (patch) | |
tree | 70309c28ec07ad9854155507dec6a5b1aee53a23 /src/csharp | |
parent | a207a042b78d56dc51dd3682160eadf50c2c2753 (diff) |
iOS (and probably other AOT platforms) needs to have delegates registered
- if a managed delegate is going to be passed to native code, then it requires an attribute
- instead of depending on Xamarin.iOS for this, we can just create our own, the iOS runtime just checks for the type name
- reference: https://docs.microsoft.com/en-gb/xamarin/ios/internals/limitations#reverse-callbacks
Diffstat (limited to 'src/csharp')
-rw-r--r-- | src/csharp/Grpc.Core/Internal/NativeLogRedirector.cs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/csharp/Grpc.Core/Internal/NativeLogRedirector.cs b/src/csharp/Grpc.Core/Internal/NativeLogRedirector.cs index bf6440123a..72dd21dc94 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,15 @@ namespace Grpc.Core.Internal } } } + + [AttributeUsage(AttributeTargets.Method)] + internal sealed class MonoPInvokeCallbackAttribute : Attribute + { + public MonoPInvokeCallbackAttribute(Type type) + { + Type = type; + } + + public Type Type { get; private set; } + } } |