Bugzilla – Bug 324740
[GMCS] encodes where T: struct differently than csc
Last modified: 2008-09-19 15:13:56 UTC
---- Reported by atsushi@ximian.com 2007-07-11 06:59:55 MST ---- The example below says that T of Nullable<T> has no constraint, while it is constrained to struct. (where T : struct, new()) -------- using System; using System.Reflection; public class Test { public static void Main () { Type t = typeof (int?).GetGenericTypeDefinition (); Type n = t.GetGenericArguments () [0]; Console.WriteLine (n.GetGenericParameterConstraints ().Length); } } -------- According to .NET ildasm, T in our mscorlib Nullable<T> is constrained, so it's just that Type.GetGenericParameterConstraints() returns nothing. I believe it used to work fine before (around a year ago). And IIRC this issue existed before IMT (r81715). (Just dug into this issue today.) It is also shown as corcompare difference in mscorlib page. ---- Additional Comments From vargaz@gmail.com 2007-07-31 10:30:58 MST ---- This is a gmcs bug. In the following test case: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< using System; using System.Reflection; public class Nullable2<T> where T : struct { } public class Test { public static void Main () { Type t = typeof (Nullable2<int>).GetGenericTypeDefinition (); Type n = t.GetGenericArguments () [0]; Console.WriteLine (n.GetGenericParameterConstraints ().Length); Console.WriteLine (n.GetGenericParameterConstraints ()[0]); } } >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> gmcs encodes the constraints as: <valuetype T> while csc encodes it as: <valuetype .ctor ([mscorlib]System.ValueType) T> Unknown operating system unknown. Setting to default OS "Other".
*** This bug has been marked as a duplicate of bug 416110 ***