[runtime] Report which element failed to convert when marshalling an array between Objective-C and managed code.

This commit is contained in:
Rolf Bjarne Kvinge 2019-04-24 08:36:50 +02:00
Родитель 08ab894b4d
Коммит f83df952de
3 изменённых файлов: 19 добавлений и 3 удалений

Просмотреть файл

@ -796,4 +796,10 @@ This exception will have an inner exception which gives the reason for the failu
### MM8035: Failed to get the 'this' instance in a method call to {method}.
This exception will have an inner exception which gives the reason for the failure.
This exception will have an inner exception which gives the reason for the failure.
<a name="MM8036" />
### MM8036: Failed to marshal the value at index {index}.
This exception will have an inner exception which gives the reason for the failure.

Просмотреть файл

@ -3586,3 +3586,9 @@ This exception will have an inner exception which gives the reason for the failu
### MT8035: Failed to get the 'this' instance in a method call to {method}.
This exception will have an inner exception which gives the reason for the failure.
<a name="MT8036" />
### MT8036: Failed to convert the value at index {index} from {type} to {type}.
This exception will have an inner exception which gives the reason for the failure.

Просмотреть файл

@ -1197,8 +1197,10 @@ xamarin_convert_managed_to_nsarray_with_func (MonoArray *array, xamarin_managed_
for (int i = 0; i < length; i++) {
MonoObject *value = mono_value_box (mono_domain_get (), element_class, ptr + element_size * i);
buf [i] = convert (value, context, exception_gchandle);
if (*exception_gchandle != 0)
if (*exception_gchandle != 0) {
*exception_gchandle = xamarin_get_exception_for_element_conversion_failure (*exception_gchandle, i);
goto exception_handling;
}
}
rv = [NSArray arrayWithObjects: buf count: length];
@ -1225,8 +1227,10 @@ xamarin_convert_nsarray_to_managed_with_func (NSArray *array, MonoClass *managed
char *ptr = (char *) mono_array_addr_with_size (rv, element_size, 0);
for (int i = 0; i < length; i++) {
valueptr = convert ([array objectAtIndex: i], valueptr, managedElementType, context, exception_gchandle);
if (*exception_gchandle != 0)
if (*exception_gchandle != 0) {
*exception_gchandle = xamarin_get_exception_for_element_conversion_failure (*exception_gchandle, i);
goto exception_handling;
}
memcpy (ptr, valueptr, element_size);
ptr += element_size;
}