Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception 'Internal CLR Error' raises when try intercept a generic method #27

Closed
Hitmasu opened this issue May 22, 2021 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@Hitmasu
Copy link
Owner

Hitmasu commented May 22, 2021

When try intercept a generic method, a exception will raise:

Fatal error. Internal CLR error. (0x80131506)
   at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean, Boolean)
   at System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Reflection.MethodBase.Invoke(System.Object, System.Object[])
   at Jitex.Utils.MethodHelper.GetMethodFromHandle(IntPtr)
   at Jitex.Intercept.CallManager..ctor(IntPtr, System.Object[] ByRef, Boolean)
   at Program.Sum.Jitex.SumJitex(IntPtr, Int32, Int32)
   at HelloWorldJitex.Program.Main(System.String[])

How to reproduce:

static void Main(string[] args)
{
    JitexManager.AddMethodResolver(MethodResolver);
    JitexManager.AddInterceptor(InterceptorCallAsync);
    Sum<int>(5, 5);
}

public static int Sum<T>(int n1, int n2) => n1 + n2;

private static async ValueTask InterceptorCallAsync(CallContext context)
{
}

private static void MethodResolver(MethodContext context)
{
    if (context.Method.Name == "Sum")
        context.InterceptCall();
}
@Hitmasu Hitmasu added the bug Something isn't working label May 22, 2021
@Hitmasu Hitmasu self-assigned this May 22, 2021
@Hitmasu
Copy link
Owner Author

Hitmasu commented Jun 7, 2021

Resolved on #30

@Hitmasu Hitmasu closed this as completed Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant