Bugzilla – Bug 319415
[GMCS] [PATCH] MethodInfo.MakeGenericMethod() returns null when the count of args is unexpected
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by atsushi@ximian.com 2005-10-27 15:28:01 MST ---- When users pass a wrong number of Type arguments to MethodInfo.MakeGenericMethod(), it should raise ArgumentException, while we just return null. using System; using System.Reflection; class Goo { public void Foo<T> () {} public static void Main () { MethodInfo mi = typeof (Goo).GetMethod ("Foo"); MethodInfo gmi = mi.MakeGenericMethod (); Console.WriteLine (gmi == null); } } Actual Results: prints "True". Expected Results: something like: Unhandled Exception: System.ArgumentException: The type or method has 1 generic parameter(s) but 0 generic argument(s) were provided. How often does this happen? consitently. Additional Information: Attaching a runtime patch. ---- Additional Comments From atsushi@ximian.com 2005-10-27 15:28:37 MST ---- Created an attachment (id=168742) proposed fix ---- Additional Comments From atsushi@ximian.com 2005-10-27 15:29:31 MST ---- Maybe Martin again? ---- Additional Comments From martin@ximian.com 2005-10-28 18:20:03 MST ---- Well, I'd prefer throwing the exception in managed code if possible, but besides that it looks ok. ---- Additional Comments From atsushi@ximian.com 2005-11-08 14:02:35 MST ---- Created an attachment (id=168743) Yeah. Thus, managed version ---- Additional Comments From atsushi@ximian.com 2005-11-16 15:50:52 MST ---- Fixed in svn (r53143). Imported an attachment (id=168742) Imported an attachment (id=168743) Unknown operating system unknown. Setting to default OS "Other".