Skip to content

Commit f2f35f9

Browse files
authored
Provide more information to the user about usage of MonoPInvokeCallback (#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.
1 parent aec37df commit f2f35f9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/mono/mono/mini/aot-compiler.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5207,8 +5207,11 @@ add_native_to_managed_wrappers (MonoAotCompile *acfg)
52075207

52085208
sig = mono_method_signature_internal (e->ctor);
52095209

5210-
g_assert (sig->param_count == 1);
5211-
g_assert (sig->params [0]->type == MONO_TYPE_CLASS && !strcmp (m_class_get_name (mono_class_from_mono_type_internal (sig->params [0])), "Type"));
5210+
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"))) {
5211+
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",
5212+
mono_method_full_name (method, TRUE));
5213+
exit (1);
5214+
}
52125215

52135216
/*
52145217
* Decode the cattr manually since we can't create objects

0 commit comments

Comments
 (0)