Merge pull request #16094 from jtattermusch/mark_native_callbacks

Mark native callbacks with MonoPInvokeCallback
pull/16099/head
Jan Tattermusch 7 years ago committed by GitHub
commit 53d2899374
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      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; }
}
}

Loading…
Cancel
Save