Merge pull request #1323 from StephenMcConnel/bug-23591
[mono.git] / mcs / class / corlib / System.Reflection / MethodInfo.cs
index 68ac1aa7ec14aacf50229656821b5afb3d0d92b9..74f96f55428f03dcc775dcd1c09698251f8af648 100644 (file)
@@ -33,53 +33,44 @@ using System.Runtime.InteropServices;
 
 namespace System.Reflection {
 
-#if NET_2_0
        [ComVisible (true)]
        [ComDefaultInterfaceAttribute (typeof (_MethodInfo))]
-#endif
        [Serializable]
        [ClassInterface(ClassInterfaceType.None)]
+#if MOBILE
+       public abstract class MethodInfo: MethodBase {
+#else
        public abstract class MethodInfo: MethodBase, _MethodInfo {
-
+#endif
                public abstract MethodInfo GetBaseDefinition();
 
-               protected MethodInfo() {
+               internal virtual MethodInfo GetBaseMethod ()
+               {
+                       return this;
                }
 
-#if ONLY_1_1
-               public new Type GetType ()
-               {
-                       return base.GetType ();
+               protected MethodInfo() {
                }
-#endif
+
 
                public override MemberTypes MemberType { get {return MemberTypes.Method;} }
 
-#if NET_2_0
-               [MonoTODO]
                public virtual Type ReturnType {
                        get { return null; }
                }
-#else
-               public abstract Type ReturnType { get; }
-#endif
 
                public abstract ICustomAttributeProvider ReturnTypeCustomAttributes { get; }
 
-               // FIXME: when this method is uncommented, corlib fails
-               // to build
-/*
-               [DebuggerStepThrough]
-               [DebuggerHidden]
-               public new object Invoke (object obj, object[] parameters)
+#if !MOBILE
+               void _MethodInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
                {
-                       return base.Invoke (obj, parameters);
+                       throw new NotImplementedException ();
                }
-*/
 
-               void _MethodInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
+               Type _MethodInfo.GetType ()
                {
-                       throw new NotImplementedException ();
+                       // Required or object::GetType becomes virtual final
+                       return base.GetType ();
                }
 
                void _MethodInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
@@ -96,15 +87,15 @@ namespace System.Reflection {
                {
                        throw new NotImplementedException ();
                }
+#endif
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
                [ComVisible (true)]
                public virtual MethodInfo GetGenericMethodDefinition ()
                {
                        throw new NotSupportedException ();
                }
 
-               public virtual MethodInfo MakeGenericMethod (params Type [] types)
+               public virtual MethodInfo MakeGenericMethod (params Type [] typeArguments)
                {
                        throw new NotSupportedException (this.GetType().ToString ());
                }
@@ -116,6 +107,7 @@ namespace System.Reflection {
                        return Type.EmptyTypes;
                }
 
+#if !NET_4_0
                public override bool IsGenericMethod {
                        get {
                                return false;
@@ -133,12 +125,54 @@ namespace System.Reflection {
                                return false;
                        }
                }
+#endif
 
                public virtual ParameterInfo ReturnParameter {
                        get {
                                throw new NotSupportedException ();
                        }
                }
+
+#if NET_4_0
+               public override bool Equals (object obj)
+               {
+                       return obj == (object) this;
+               }
+
+               public override int GetHashCode ()
+               {
+                       return base.GetHashCode ();
+               }
+
+               public static bool operator == (MethodInfo left, MethodInfo right)
+               {
+                       if ((object)left == (object)right)
+                               return true;
+                       if ((object)left == null ^ (object)right == null)
+                               return false;
+                       return left.Equals (right);
+               }
+
+               public static bool operator != (MethodInfo left, MethodInfo right)
+               {
+                       if ((object)left == (object)right)
+                               return false;
+                       if ((object)left == null ^ (object)right == null)
+                               return true;
+                       return !left.Equals (right);
+               }
+#endif
+
+#if NET_4_5
+               public virtual Delegate CreateDelegate (Type delegateType)
+               {
+                       return Delegate.CreateDelegate (delegateType, this);
+               }
+
+               public virtual Delegate CreateDelegate (Type delegateType, object target)
+               {
+                       return Delegate.CreateDelegate (delegateType, target, this);
+               }
 #endif
        }
 }