DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="1.1.0" />

 ManagedMethodPointer

Acts as modifier type for the parameter representing pointer to the managed method.
using System; using System.Runtime.CompilerServices; namespace DotNext.Runtime.CompilerServices { public readonly struct ManagedMethodPointer : IEquatable<ManagedMethodPointer> { private readonly IntPtr methodPtr; internal ManagedMethodPointer(IntPtr methodPtr) { this.methodPtr = methodPtr; } internal ManagedMethodPointer(RuntimeMethodHandle method) { methodPtr = method.GetFunctionPointer(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal void InvokeStaticVoid<TSource>(TSource source, Span<char> buffer, ReadOnlySpan<char> allowedChars) where TSource : class { ; } public bool Equals(ManagedMethodPointer other) { return methodPtr == other.methodPtr; } public override bool Equals(object other) { if (other is ManagedMethodPointer) { ManagedMethodPointer other2 = (ManagedMethodPointer)other; return Equals(other2); } return false; } public override int GetHashCode() { return methodPtr.GetHashCode(); } public override string ToString() { return methodPtr.ToString("X"); } public static bool operator ==(ManagedMethodPointer x, ManagedMethodPointer y) { return x.methodPtr == y.methodPtr; } public static bool operator !=(ManagedMethodPointer x, ManagedMethodPointer y) { return x.methodPtr != y.methodPtr; } } }