Array.CreateInstance (typeof (Int32), (long[])null);
}
+ [Test]
+ public void CreateInstanceVoid ()
+ {
+ Assert.Throws<NotSupportedException> (delegate () {
+ Array.CreateInstance (typeof (void), 1);
+ });
+ }
+
[Test]
public void TestGetEnumerator() {
String[] s1 = {"this", "is", "a", "test"};
object o = Array.CreateInstance (typeof (global::System.TypedReference), 1);
}
+ [Test]
+ public void MakeArrayTypeLargeRank ()
+ {
+ Assert.Throws<TypeLoadException> (delegate () {
+ typeof (int).MakeArrayType (33);
+ });
+ }
+
[ComVisible (true)]
public class ComFoo<T> {
}
klass->parent = parent;
klass->instance_size = mono_class_instance_size (klass->parent);
- if (eclass->byval_arg.type == MONO_TYPE_TYPEDBYREF || eclass->byval_arg.type == MONO_TYPE_VOID) {
+ if (eclass->byval_arg.type == MONO_TYPE_TYPEDBYREF) {
/*Arrays of those two types are invalid.*/
MonoError prepared_error;
error_init (&prepared_error);
- mono_error_set_invalid_program (&prepared_error, "Arrays of void or System.TypedReference types are invalid.");
+ mono_error_set_invalid_program (&prepared_error, "Arrays of System.TypedReference types are invalid.");
mono_class_set_failure (klass, mono_error_box (&prepared_error, klass->image));
mono_error_cleanup (&prepared_error);
} else if (eclass->enumtype && !mono_class_enum_basetype (eclass)) {
klass->this_arg = klass->byval_arg;
klass->this_arg.byref = 1;
+ if (rank > 32) {
+ MonoError prepared_error;
+ error_init (&prepared_error);
+ name = mono_type_get_full_name (klass);
+ mono_error_set_type_load_class (&prepared_error, klass, "%s has too many dimensions.", name);
+ mono_class_set_failure (klass, mono_error_box (&prepared_error, klass->image));
+ mono_error_cleanup (&prepared_error);
+ g_free (name);
+ }
+
mono_loader_lock ();
/* Check cache again */
if (mono_error_set_pending_exception (&error))
return NULL;
+ if (klass->element_class->byval_arg.type == MONO_TYPE_VOID) {
+ mono_set_pending_exception (mono_get_exception_not_supported ("Arrays of System.Void are not supported."));
+ return NULL;
+ }
+
if (bounds && (mono_array_length (bounds) == 1) && (mono_array_get (bounds, gint32, 0) != 0))
/* vectors are not the same as one dimensional arrays with no-zero bounds */
bounded = TRUE;
name = mono_type_get_full_name (klass);
mono_error_set_type_load_name (error, name, g_strdup (""), "");
}
+
ICALL_EXPORT MonoReflectionTypeHandle
ves_icall_RuntimeType_make_array_type (MonoReflectionTypeHandle ref_type, int rank, MonoError *error)
{
else
aklass = mono_bounded_array_class_get (klass, rank, TRUE);
+ if (mono_class_has_failure (aklass)) {
+ mono_error_set_for_class_failure (error, aklass);
+ return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
+ }
+
MonoDomain *domain = MONO_HANDLE_DOMAIN (ref_type);
return mono_type_get_object_handle (domain, &aklass->byval_arg, error);
}