From 1add55dbda076393bea0419b707f3353235d05ff Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 21 Jul 2018 19:40:19 +0200 Subject: 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 --- src/csharp/Grpc.Core/Internal/NativeLogRedirector.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/csharp') 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; } + } } -- cgit v1.2.3