Bug 319415 (MONO76575) - [GMCS] [PATCH] MethodInfo.MakeGenericMethod() returns null when the count of args is unexpected
Summary: [GMCS] [PATCH] MethodInfo.MakeGenericMethod() returns null when the count of ...
Status: RESOLVED FIXED
Alias: MONO76575
Product: Mono: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Minor
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-27 22:28 UTC by Atsushi Enomoto
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
proposed fix (913 bytes, patch)
2005-10-27 22:28 UTC, Thomas Wiest
Details | Diff
Yeah. Thus, managed version (3.98 KB, patch)
2005-11-08 21:02 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:36:31 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".