[Mono-bugs] [Bug 78068][Nor] New - Type.GetMethod for generic type

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Apr 10 04:58:11 EDT 2006


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 atsushi at ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=78068

--- shadow/78068	2006-04-10 04:58:11.000000000 -0400
+++ shadow/78068.tmp.26396	2006-04-10 04:58:11.000000000 -0400
@@ -0,0 +1,102 @@
+Bug#: 78068
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: atsushi at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: martin at ximian.com,rharinath at novell.com
+Summary: Type.GetMethod for generic type
+
+The following code shows us that for generic types Type.GetMethod() returns
+an instantiated generic method definition, not the generic method
+definition. I'm not sure which (Mono or MS) is correct though.
+
+--------
+
+using System;
+using System.Reflection;
+
+public class Test
+{
+        public static void Main ()
+        {
+                MethodInfo mi1 = typeof
+(MyList<int>).GetGenericTypeDefinition ().GetMethod ("ConvertAll");
+                MethodInfo mi2 = typeof (MyList<int>).GetMethod ("ConvertAll");
+                Console.WriteLine (mi1);
+                Console.WriteLine (mi2);
+                Console.WriteLine (mi1.GetParameters () [0].ParameterType);
+                Console.WriteLine (mi2.GetParameters () [0].ParameterType);
+                Console.WriteLine ("{0} {1}", mi1.IsGenericMethodDefinition,
+                        mi1.IsGenericMethod);
+                Console.WriteLine ("{0} {1}", mi2.IsGenericMethodDefinition,
+                        mi2.IsGenericMethod);
+                MethodInfo mi3 = mi2.GetGenericMethodDefinition ();
+                Console.WriteLine ("{0} {1}", mi3.IsGenericMethodDefinition,
+                        mi3.IsGenericMethod);
+                Console.WriteLine (mi2 == mi3);
+        }
+}
+
+public class MyList<T>
+{
+        public TOutput ConvertAll<TOutput> (Foo<T,TOutput> arg)
+        {
+                return default (TOutput);
+        }
+        public T ConvertAll2 (MyList<T> arg)
+        {
+                return default (T);
+        }
+}
+
+public class Foo<T,TOutput>
+{
+}
+----
+
+
+Actual Results:
+
+.TOutput ConvertAll(.Foo`2)
+.TOutput ConvertAll(.Foo`2)
+Foo`2[T,TOutput]
+Foo`2[System.Int32,TOutput]
+True True
+False True
+True True
+False
+
+Expected Results:
+
+TOutput ConvertAll[TOutput](Foo`2[T,TOutput])
+TOutput ConvertAll[TOutput](Foo`2[System.Int32,TOutput])
+Foo`2[T,TOutput]
+Foo`2[System.Int32,TOutput]
+True True
+True True
+True True
+True
+
+How often does this happen? 
+
+consistently.
+
+Additional Information:
+
+ConvertAll2() is totally extraneous in this code but it would also show
+some differences (at least as ToString() results) - I'm not sure if the
+cause of the problem is the same.
+
+It is an extracted example from System.Collections.Generic.List<T>.
+
+The results are irrelevant to the compiler (gmcs/csc).


More information about the mono-bugs mailing list