Merge pull request #1323 from StephenMcConnel/bug-23591
[mono.git] / mcs / class / corlib / System.Reflection / MethodInfo.cs
index b736309ae3bfb7cce9589daadd281c9279a2f5cd..74f96f55428f03dcc775dcd1c09698251f8af648 100644 (file)
@@ -33,46 +33,46 @@ 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;} }
-               public abstract Type ReturnType { get; }
-               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)
-               {
-                       return base.Invoke (obj, parameters);
+               public virtual Type ReturnType {
+                       get { return null; }
                }
-*/
 
+               public abstract ICustomAttributeProvider ReturnTypeCustomAttributes { get; }
+
+#if !MOBILE
                void _MethodInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
                {
                        throw new NotImplementedException ();
                }
 
+               Type _MethodInfo.GetType ()
+               {
+                       // Required or object::GetType becomes virtual final
+                       return base.GetType ();
+               }
+
                void _MethodInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
                {
                        throw new NotImplementedException ();
@@ -87,24 +87,27 @@ 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 ());
                }
 
                // GetGenericArguments, IsGenericMethod, IsGenericMethodDefinition
                // and ContainsGenericParameters are implemented in the derived classes.
+               [ComVisible (true)]
                public override Type [] GetGenericArguments () {
                        return Type.EmptyTypes;
                }
 
+#if !NET_4_0
                public override bool IsGenericMethod {
                        get {
                                return false;
@@ -122,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
        }
 }