Merge pull request #735 from wtfrank/bitblt
[mono.git] / mcs / class / corlib / System.Reflection / PropertyInfo.cs
index 09b7632ecb26b301176d1b038cf22b4c88f4fc52..6675d2e6c69f7bdbbf18d71b2393815e6458b947 100644 (file)
 using System.Diagnostics;
 using System.Globalization;
 using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
 
 namespace System.Reflection {
 
-#if NET_2_0
        [ComVisible (true)]
        [ComDefaultInterfaceAttribute (typeof (_PropertyInfo))]
-#endif
        [Serializable]
        [ClassInterface(ClassInterfaceType.None)]
+#if MOBILE
+       public abstract class PropertyInfo : MemberInfo {
+#else
        public abstract class PropertyInfo : MemberInfo, _PropertyInfo {
-
+#endif
                public abstract PropertyAttributes Attributes { get; }
                public abstract bool CanRead { get; }
                public abstract bool CanWrite { get; }
+               
+#if NET_4_5
+               public virtual MethodInfo GetMethod {
+                       get { return GetGetMethod(true); }
+               }
+
+               public virtual MethodInfo SetMethod {
+                       get { return GetSetMethod(true); }
+               }
+#endif
 
                public bool IsSpecialName {
                        get {return (Attributes & PropertyAttributes.SpecialName) != 0;}
@@ -71,13 +83,6 @@ namespace System.Reflection {
                
                public abstract ParameterInfo[] GetIndexParameters();
 
-#if ONLY_1_1
-               public new Type GetType ()
-               {
-                       return base.GetType ();
-               }
-#endif
-
                public MethodInfo GetSetMethod()
                {
                        return GetSetMethod (false);
@@ -91,7 +96,16 @@ namespace System.Reflection {
                {
                        return GetValue(obj, BindingFlags.Default, null, index, null);
                }
-               
+
+#if NET_4_5
+               [DebuggerHidden]
+               [DebuggerStepThrough]
+               public object GetValue (object obj)
+               {
+                       return GetValue(obj, BindingFlags.Default, null, null, null);
+               }
+#endif
+
                public abstract object GetValue (object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture);
                
                [DebuggerHidden]
@@ -100,36 +114,81 @@ namespace System.Reflection {
                {
                        SetValue (obj, value, BindingFlags.Default, null, index, null);
                }
-               
+
+#if NET_4_5
+               [DebuggerHidden]
+               [DebuggerStepThrough]
+               public void SetValue (object obj, object value)
+               {
+                       SetValue (obj, value, BindingFlags.Default, null, null, null);
+               }
+#endif
+
                public abstract void SetValue (object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture);
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
-               [MonoTODO]
                public virtual Type[] GetOptionalCustomModifiers () {
-                       throw new NotImplementedException ();
+                       return Type.EmptyTypes;
                }
 
-               [MonoTODO]
                public virtual Type[] GetRequiredCustomModifiers () {
-                       throw new NotImplementedException ();
+                       return Type.EmptyTypes;
+               }
+
+               static NotImplementedException CreateNIE ()
+               {
+                       return new NotImplementedException ();
                }
 
-               [MonoTODO]
                public virtual object GetConstantValue () {
-                       throw new NotImplementedException ();
+                       throw CreateNIE ();
                }
 
-               [MonoTODO]
                public virtual object GetRawConstantValue() {
-                       throw new NotImplementedException ();
+                       throw CreateNIE ();
+               }
+
+#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 == (PropertyInfo left, PropertyInfo 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 != (PropertyInfo left, PropertyInfo right)
+               {
+                       if ((object)left == (object)right)
+                               return false;
+                       if ((object)left == null ^ (object)right == null)
+                               return true;
+                       return !left.Equals (right);
                }
 #endif
 
+#if !MOBILE
                void _PropertyInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
                {
                        throw new NotImplementedException ();
                }
 
+               Type _PropertyInfo.GetType ()
+               {
+                       // Required or object::GetType becomes virtual final
+                       return base.GetType ();
+               }               
+
                void _PropertyInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
                {
                        throw new NotImplementedException ();
@@ -144,5 +203,6 @@ namespace System.Reflection {
                {
                        throw new NotImplementedException ();
                }
+#endif
        }
 }