Please do not reply to this email- if you want to comment on the bug, go to the URL shown below and enter your comments there.
Changed by [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=81392 --- shadow/81392 2007-04-18 03:35:47.000000000 -0400 +++ shadow/81392.tmp.13445 2007-04-18 03:35:47.000000000 -0400 @@ -0,0 +1,92 @@ +Bug#: 81392 +Product: Mono: Compilers +Version: unspecified +OS: All +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: C# +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: Generic constraints not compiled correctly + +With this test case: + +using System; +using System.Reflection; + +class foo +{ + public static int GenericCompare<T> (Nullable<T> left, Nullable<T> right) +where T: struct + { + return 0; + } + + public static void Main () + { + MethodInfo mi = typeof (foo).GetMethod ("GenericCompare"); + Console.WriteLine (mi.Name); + + //MethodInfo mi = method as MethodInfo; + Type [] genArgs = mi == null ? Type.EmptyTypes : + mi.GetGenericArguments (); + if (genArgs.Length > 0) { + string [] genArgNames = new string [genArgs.Length]; + for (int i = 0; i < genArgs.Length; i++) { + genArgNames [i] = genArgs [i].Name; + string genArgCsts = String.Empty; + Console.WriteLine ("genArgs [i]: " + genArgs [i]); + Type [] gcs = genArgs [i].GetGenericParameterConstraints (); + Console.WriteLine ("gcs.Length: " + gcs.Length); + if (gcs.Length > 0) { + string [] gcNames = new string [gcs.Length]; + for (int g = 0; g < gcs.Length; g++) + gcNames [g] = gcs [g].FullName; + genArgCsts = String.Concat ( + "(", + string.Join (", ", gcNames), + ") ", + genArgNames [i]); + } + else + genArgCsts = genArgNames [i]; + if ((genArgs [i].GenericParameterAttributes & +GenericParameterAttributes.ReferenceTypeConstraint) != 0) + genArgCsts = "class " + genArgCsts; + else if ((genArgs [i].GenericParameterAttributes & +GenericParameterAttributes.NotNullableValueTypeConstraint) != 0) + genArgCsts = "struct " + genArgCsts; + genArgNames [i] = genArgCsts; + } + string ret = String.Format ("{0}<{2}>({1})", + "name", + "parms", + string.Join (",", genArgNames)); + + Console.WriteLine (ret); + } + } +} + + +When compiled with gmcs, the output on both Mono and MS .NET is: + +GenericCompare +genArgs [i]: T +gcs.Length: 0 +name<struct T>(parms) + + +When compiled with csc, the output on MS .NET is: + +GenericCompare +genArgs [i]: T +gcs.Length: 1 +name<struct (System.ValueType) T>(parms) _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
