MonoExtensions.cs 638 B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using System.Runtime.InteropServices;
  4. namespace BepInEx
  5. {
  6. /// <summary>
  7. /// Contains unofficial extensions to the underlying Mono runtime.
  8. /// </summary>
  9. public static class MonoExtensions
  10. {
  11. [MethodImpl(MethodImplOptions.InternalCall)]
  12. private static extern IntPtr GetFunctionPointerForDelegateInternal2(Delegate d, CallingConvention conv);
  13. public static IntPtr GetFunctionPointerForDelegate(Delegate d, CallingConvention conv)
  14. {
  15. if (d == null)
  16. {
  17. throw new ArgumentNullException("d");
  18. }
  19. return GetFunctionPointerForDelegateInternal2(d, conv);
  20. }
  21. }
  22. }