Merge pull request #3224 from ludovic-henry/iolayer-extract-wait-handle
[mono.git] / mcs / class / corlib / System.Reflection / FieldInfo.cs
index 3243d1f97ad2029bec8678fd4d8f4c62887b1225..47021a3ffef65488a8f8281550a145b9d9186b2e 100644 (file)
@@ -6,6 +6,7 @@
 //
 // (C) Ximian, Inc.  http://www.ximian.com
 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+// Copyright 2011 Xamarin Inc (http://www.xamarin.com).
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -27,7 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 using System.Diagnostics;
-using System.Reflection.Emit;
 using System.Globalization;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
@@ -38,8 +38,11 @@ namespace System.Reflection {
        [ComDefaultInterfaceAttribute (typeof (_FieldInfo))]
        [Serializable]
        [ClassInterface(ClassInterfaceType.None)]
+#if MOBILE
+       public abstract class FieldInfo : MemberInfo {
+#else
        public abstract class FieldInfo : MemberInfo, _FieldInfo {
-
+#endif
                public abstract FieldAttributes Attributes {get;}
                public abstract RuntimeFieldHandle FieldHandle {get;}
 
@@ -132,13 +135,6 @@ namespace System.Reflection {
 
                public abstract void SetValue (object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture);
 
-#if ONLY_1_1
-               public new Type GetType ()
-               {
-                       return base.GetType ();
-               }
-#endif
-
                [DebuggerHidden]
                [DebuggerStepThrough]
                public void SetValue (object obj, object value)
@@ -183,27 +179,19 @@ namespace System.Reflection {
                }
 
                [CLSCompliant(false)]
-               [MonoTODO("Not implemented")]
                public virtual object GetValueDirect (TypedReference obj)
                {
-                       throw new NotImplementedException ();
+                       throw new NotSupportedException(Environment.GetResourceString("NotSupported_AbstractNonCLS"));
                }
 
                [CLSCompliant(false)]
-               [MonoTODO("Not implemented")]
                public virtual void SetValueDirect (TypedReference obj, object value)
                {
-                       throw new NotImplementedException ();
+                       throw new NotSupportedException(Environment.GetResourceString("NotSupported_AbstractNonCLS"));
                }
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               private extern UnmanagedMarshal GetUnmanagedMarshal ();
-
-               internal virtual UnmanagedMarshal UMarshal {
-                       get {
-                               return GetUnmanagedMarshal ();
-                       }
-               }
+               private extern MarshalAsAttribute get_marshal_info ();
 
                internal object[] GetPseudoCustomAttributes ()
                {
@@ -215,7 +203,7 @@ namespace System.Reflection {
                        if (DeclaringType.IsExplicitLayout)
                                count ++;
 
-                       UnmanagedMarshal marshalAs = UMarshal;
+                       MarshalAsAttribute marshalAs = get_marshal_info ();
                        if (marshalAs != null)
                                count ++;
 
@@ -229,7 +217,7 @@ namespace System.Reflection {
                        if (DeclaringType.IsExplicitLayout)
                                attrs [count ++] = new FieldOffsetAttribute (GetFieldOffset ());
                        if (marshalAs != null)
-                               attrs [count ++] = marshalAs.ToMarshalAsAttribute ();
+                               attrs [count ++] = marshalAs;
 
                        return attrs;
                }
@@ -257,10 +245,9 @@ namespace System.Reflection {
                }
 
 
-#if NET_4_0
                public override bool Equals (object obj)
                {
-                       return obj == this;
+                       return obj == (object) this;
                }
 
                public override int GetHashCode ()
@@ -285,12 +272,37 @@ namespace System.Reflection {
                                return true;
                        return !left.Equals (right);
                }
-#endif
+               
+               public virtual bool IsSecurityCritical {
+                       get {
+                               throw new NotSupportedException ();
+                       }
+               }
+               
+               public virtual bool IsSecuritySafeCritical {
+                       get {
+                               throw new NotSupportedException ();
+                       }
+               }
+
+               public virtual bool IsSecurityTransparent {
+                       get {
+                               throw new NotSupportedException ();
+                       }
+               }
+
+#if !MOBILE
                void _FieldInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
                {
                        throw new NotImplementedException ();
                }
 
+               Type _FieldInfo.GetType ()
+               {
+                       // Required or object::GetType becomes virtual final
+                       return base.GetType ();
+               }
+
                void _FieldInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
                {
                        throw new NotImplementedException ();
@@ -305,5 +317,6 @@ namespace System.Reflection {
                {
                        throw new NotImplementedException ();
                }
+#endif
        }
 }