{
this.generic_type = tb;
this.type_arguments = args;
- register_with_runtime (this); /*Temporary hack while*/
+ /*
+ This is a temporary hack until we can fix the rest of the runtime
+ to properly handle this class to be a complete UT.
+
+ We must not regisrer this with the runtime after the type is created
+ otherwise created_type.MakeGenericType will return an instance of MonoGenericClass,
+ which is very very broken.
+ */
+ if (tb is TypeBuilder && !(tb as TypeBuilder).is_created)
+ register_with_runtime (this);
+
}
Assert.Fail ("#13");
} catch (NotSupportedException) { }
}
+
+ [Test]
+ public void ClassMustNotBeRegisteredAfterTypeBuilderIsFinished ()
+ {
+ TypeBuilder tb = module.DefineType ("foo.type");
+ tb.DefineGenericParameters ("T");
+
+ var c = tb.CreateType ();
+
+ var sreInst = tb.MakeGenericType (typeof (int));
+ var rtInst = c.MakeGenericType (typeof (int));
+
+ Assert.AreNotSame (sreInst, rtInst, "#1");
+
+ /*This must not throw*/
+ rtInst.IsDefined (typeof (int), true);
+ }
}
+
#endif
}
public void MakeGenericType_BadUserType ()
{
Type ut = new UserType (null);
- try {
- Type t = typeof (Foo<>).MakeGenericType (ut);
- Assert.Fail ("#1");
- } catch (ArgumentException) {
- }
+ Type t = typeof (Foo<>).MakeGenericType (ut);
+ var g0 = t.GetGenericArguments () [0];
+ Assert.AreSame (g0, ut, "#1");
}
-
+
[Test]
public void MakeGenericType_WrongNumOfArguments ()
{