[corlib] Fixed StringBuilder construction bugs in marshalling caused by changes to...
[mono.git] / mcs / class / corlib / System.Reflection / MemberInfo.cs
index bfeda0c40a832fa0284413f85c92b129c8e3de38..64d9c8d92134c825ac3a633bb748f269c5589cc8 100644 (file)
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Security.Permissions;
+using System.Collections.Generic;
 
 namespace System.Reflection {
 
-#if NET_2_0
        [ComVisible (true)]
        [ComDefaultInterfaceAttribute (typeof (_MemberInfo))]
-#endif
        [Serializable]
        [ClassInterface(ClassInterfaceType.None)]
        [PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
+#if MOBILE
+       public abstract class MemberInfo : ICustomAttributeProvider {
+#else
        public abstract class MemberInfo : ICustomAttributeProvider, _MemberInfo {
+#endif
 
                protected MemberInfo ()
                {
@@ -62,42 +65,71 @@ namespace System.Reflection {
                        get;
                }
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
                public virtual Module Module {
                        get {
                                return DeclaringType.Module;
                        }
                }
-#endif
-
-#if ONLY_1_1
-               public new Type GetType ()
-               {
-                       return base.GetType ();
-               }
-#endif
 
-               public abstract bool IsDefined (Type attribute_type, bool inherit);
+               public abstract bool IsDefined (Type attributeType, bool inherit);
 
                public abstract object [] GetCustomAttributes (bool inherit);
 
-               public abstract object [] GetCustomAttributes (Type attribute_type, bool inherit);
+               public abstract object [] GetCustomAttributes (Type attributeType, bool inherit);
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
-               public
-#else
-               internal
-#endif
-               virtual extern int MetadataToken {
+               public virtual extern int MetadataToken {
                        [MethodImplAttribute (MethodImplOptions.InternalCall)]
                        get;
                }
 
+               public override bool Equals (object obj)
+               {
+                       return obj == (object) this;
+               }
+
+               public override int GetHashCode ()
+               {
+                       return base.GetHashCode ();
+               }
+
+               public static bool operator == (MemberInfo left, MemberInfo 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 != (MemberInfo left, MemberInfo right)
+               {
+                       if ((object)left == (object)right)
+                               return false;
+                       if ((object)left == null ^ (object)right == null)
+                               return true;
+                       return !left.Equals (right);
+               }
+
+               public virtual IList<CustomAttributeData> GetCustomAttributesData () {
+                       throw new NotImplementedException ();
+               }
+
+               public virtual IEnumerable<CustomAttributeData> CustomAttributes {
+                       get { return GetCustomAttributesData (); }
+               }
+
+#if !MOBILE
                void _MemberInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
                {
                        throw new NotImplementedException ();
                }
 
+               Type _MemberInfo.GetType ()
+               {
+                       // Required or object::GetType becomes virtual final
+                       return base.GetType ();
+               }
+
                void _MemberInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
                {
                        throw new NotImplementedException ();
@@ -112,5 +144,6 @@ namespace System.Reflection {
                {
                        throw new NotImplementedException ();
                }
+#endif
        }
 }