diff options
author | Jo Shields <directhex@apebox.org> | 2013-12-03 23:54:15 +0000 |
---|---|---|
committer | Jo Shields <directhex@apebox.org> | 2013-12-03 23:54:15 +0000 |
commit | 79d5fb381b8f669e2d81d62014413d006db3b7b4 (patch) | |
tree | 8e8f9adec42cde9879034d2a98d8096940d0b861 | |
parent | 2ed3a85baa3dd3de47cd989a6d660ec80d0778f8 (diff) | |
parent | 3fc971b0114a5e62b406dd1afb5d3c5c33151e69 (diff) | |
download | mono-79d5fb381b8f669e2d81d62014413d006db3b7b4.tar.gz |
Merge branch 'master-patches/fix_fsharp'
-rw-r--r-- | mcs/class/corlib/System.Reflection/MethodBase.cs | 13 | ||||
-rw-r--r-- | mcs/class/corlib/Test/System.Reflection/BinderTests.cs | 87 |
2 files changed, 98 insertions, 2 deletions
diff --git a/mcs/class/corlib/System.Reflection/MethodBase.cs b/mcs/class/corlib/System.Reflection/MethodBase.cs index 671f11d005..dd57144a21 100644 --- a/mcs/class/corlib/System.Reflection/MethodBase.cs +++ b/mcs/class/corlib/System.Reflection/MethodBase.cs @@ -88,8 +88,17 @@ namespace System.Reflection { // This is a quick version for our own use. We should override // it where possible so that it does not allocate an array. // - internal abstract ParameterInfo[] GetParametersInternal (); - internal abstract int GetParametersCount (); + internal virtual ParameterInfo[] GetParametersInternal () + { + // Override me + return GetParameters (); + } + + internal virtual int GetParametersCount () + { + // Override me + return GetParametersInternal ().Length; + } internal virtual Type GetParameterType (int pos) { throw new NotImplementedException (); diff --git a/mcs/class/corlib/Test/System.Reflection/BinderTests.cs b/mcs/class/corlib/Test/System.Reflection/BinderTests.cs index 33aea7c973..b0550788f4 100644 --- a/mcs/class/corlib/Test/System.Reflection/BinderTests.cs +++ b/mcs/class/corlib/Test/System.Reflection/BinderTests.cs @@ -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 { @@ -1395,5 +1469,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); + } } } |