[runtime] Throw exception for condition we don't handle in the dynamic registrar. (#20568)
Throw an exception for a condition we don't handle in the dynamic registrar: calling a base Objective-C constructor (init method) with arguments. Our current implementation to call the base Objective-C constructor doesn't handle any arguments, so if the method actually takes any arguments, those will just be random memory. In other words: a consistent exception is better than a random invalid memory access.
This commit is contained in:
Родитель
8ea6cd6a66
Коммит
7e8e887d5d
|
@ -107,6 +107,13 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
|
|||
}
|
||||
|
||||
if (has_nsobject) {
|
||||
if (strchr (sel_getName (sel), ':') != NULL) {
|
||||
char *msg = xamarin_strdup_printf ("The dynamic registrar does not support calling base Objective-C constructors with arguments (type: %s, selector: %s). Please use any of the static registrars.", class_getName ([self class]), sel_getName (sel));
|
||||
exception_gchandle = xamarin_create_product_exception (8058, msg);
|
||||
xamarin_free (msg);
|
||||
xamarin_process_managed_exception_gchandle (exception_gchandle);
|
||||
return;
|
||||
}
|
||||
self = xamarin_invoke_objc_method_implementation (self, sel, (IMP) xamarin_ctor_trampoline);
|
||||
marshal_return_value (context, "|", __SIZEOF_POINTER__, self, NULL, false, NULL, NULL, &exception_gchandle);
|
||||
xamarin_process_managed_exception_gchandle (exception_gchandle);
|
||||
|
|
|
@ -4266,5 +4266,14 @@ namespace Xamarin.Bundler {
|
|||
return ResourceManager.GetString("MX8057", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The dynamic registrar does not support calling base Objective-C constructors with arguments (type: %s, selector: %s). Please use any of the static registrars..
|
||||
/// </summary>
|
||||
public static string MX8058 {
|
||||
get {
|
||||
return ResourceManager.GetString("MX8058", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2271,4 +2271,8 @@
|
|||
<value>.NET for {0} does not support server garbage collection.</value>
|
||||
<comment>{0}: the platform (iOS, macOS, etc.)</comment>
|
||||
</data>
|
||||
|
||||
<data name="MX8058" xml:space="preserve">
|
||||
<value>The dynamic registrar does not support calling base Objective-C constructors with arguments (type: %s, selector: %s). Please use any of the static registrars.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
Загрузка…
Ссылка в новой задаче