Skip to content

Commit

Permalink
Provide more information to the user about usage of MonoPInvokeCallba…
Browse files Browse the repository at this point in the history
…ck (#82653)

Unity's IL2CPP accepts a MonoPInvokeCallback constructor without any argument. When porting interop code from Unity's IL2CPP to Mono AOT this gives a hint to the user about what they need to fix.
  • Loading branch information
jbevain authored Feb 25, 2023
1 parent aec37df commit f2f35f9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -5207,8 +5207,11 @@ add_native_to_managed_wrappers (MonoAotCompile *acfg)

sig = mono_method_signature_internal (e->ctor);

g_assert (sig->param_count == 1);
g_assert (sig->params [0]->type == MONO_TYPE_CLASS && !strcmp (m_class_get_name (mono_class_from_mono_type_internal (sig->params [0])), "Type"));
if (sig->param_count != 1 || !(sig->params [0]->type == MONO_TYPE_CLASS && !strcmp (m_class_get_name (mono_class_from_mono_type_internal (sig->params [0])), "Type"))) {
g_warning ("AOT restriction: The attribute [MonoPInvokeCallback] used on method '%s' must take a System.Type argument. See https://docs.microsoft.com/xamarin/ios/internals/limitations#reverse-callbacks",
mono_method_full_name (method, TRUE));
exit (1);
}

/*
* Decode the cattr manually since we can't create objects
Expand Down

0 comments on commit f2f35f9

Please sign in to comment.