Add test from Jb Evain to test biner with user method types
authorMarek Safar <marek.safar@gmail.com>
Wed, 6 Mar 2013 09:23:47 +0000 (10:23 +0100)
committerMarek Safar <marek.safar@gmail.com>
Wed, 6 Mar 2013 10:18:04 +0000 (11:18 +0100)
mcs/class/corlib/System.Reflection/MethodBase.cs
mcs/class/corlib/Test/System.Reflection/BinderTests.cs

index add58904bf38f9f48dd84546f1c08dd556d1cd15..294a71e4c33e4ab191a7fdf7dc40bcb26136cee0 100644 (file)
@@ -94,12 +94,14 @@ namespace System.Reflection {
                //
                internal virtual ParameterInfo[] GetParametersInternal ()
                {
-                       throw new NotImplementedException ();
+                       // Override me
+                       return GetParameters ();
                }
 
                internal virtual int GetParametersCount ()
                {
-                       throw new NotImplementedException ();
+                       // Override me
+                       return GetParametersInternal ().Length;
                }
 
                internal virtual Type GetParameterType (int pos) {
index 3924ff598216bb17cba0cc8ba685a83e8f1f5bb4..08235e8cec6c5f52e4df234210a334767fdb61f3 100644 (file)
@@ -101,6 +101,80 @@ namespace MonoTests.System.Reflection
                }
        }
 
+       class MethodInfoWrapper : MethodInfo
+       {
+               private readonly MethodInfo method;
+               
+               public MethodInfoWrapper (MethodInfo method)
+               {
+                       this.method = method;
+               }
+               
+               public override object[] GetCustomAttributes (bool inherit)
+               {
+                       return method.GetCustomAttributes (inherit);
+               }
+               
+               public override bool IsDefined (Type attributeType, bool inherit)
+               {
+                       return method.IsDefined (attributeType, inherit);
+               }
+               
+               public override ParameterInfo[] GetParameters ()
+               {
+                       return method.GetParameters ();
+               }
+               
+               public override MethodImplAttributes GetMethodImplementationFlags ()
+               {
+                       return method.GetMethodImplementationFlags ();
+               }
+               
+               public override object Invoke (object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
+               {
+                       return method.Invoke (obj, invokeAttr, binder, parameters, culture);
+               }
+               
+               public override MethodInfo GetBaseDefinition ()
+               {
+                       return method.GetBaseDefinition ();
+               }
+               
+               public override ICustomAttributeProvider ReturnTypeCustomAttributes {
+                       get { return method.ReturnTypeCustomAttributes; }
+               }
+               
+               public override string Name {
+                       get { return method.Name; }
+               }
+               
+               public override Type ReturnType {
+                       get { return method.ReturnType; }
+               }
+               
+               public override Type DeclaringType {
+                       get { return method.DeclaringType; }
+               }
+               
+               public override Type ReflectedType {
+                       get { return method.ReflectedType; }
+               }
+               
+               public override RuntimeMethodHandle MethodHandle {
+                       get { return method.MethodHandle; }
+               }
+               
+               public override MethodAttributes Attributes {
+                       get { return method.Attributes; }
+               }
+               
+               public override object[] GetCustomAttributes (Type attributeType, bool inherit)
+               {
+                       return method.GetCustomAttributes (attributeType, inherit);
+               }
+       }
+
+
        [TestFixture]
        public class BinderTest
        {
@@ -1402,5 +1476,18 @@ namespace MonoTests.System.Reflection
                                null, // target
                                new object [] { CultureInfo.CurrentCulture, "foo{0}{1}", "bar", "baz" }));
                }
+
+               public static void CustomMethodType_Helper ()
+               {
+               }
+
+               [Test]
+               public void CustomMethodType ()
+               {
+                       var method = new MethodInfoWrapper (GetType ().GetMethod ("CustomMethodType_Helper"));
+
+                       var res = Type.DefaultBinder.SelectMethod (BindingFlags.Static | BindingFlags.Public, new[] { method }, Type.EmptyTypes, new ParameterModifier[0]);
+                       Assert.AreSame (method, res);
+               }
        }
 }