//
// (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
// 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;
namespace System.Reflection {
-#if NET_2_0
[ComVisible (true)]
[ComDefaultInterfaceAttribute (typeof (_FieldInfo))]
-#endif
[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;}
}
}
- public abstract void SetValue (object obj, object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture);
-
-#if ONLY_1_1
- public new Type GetType ()
- {
- return base.GetType ();
- }
-#endif
+ public abstract void SetValue (object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture);
[DebuggerHidden]
[DebuggerStepThrough]
public static FieldInfo GetFieldFromHandle (RuntimeFieldHandle handle)
{
+ if (handle.Value == IntPtr.Zero)
+ throw new ArgumentException ("The handle is invalid.");
return internal_from_handle_type (handle.Value, IntPtr.Zero);
}
-#if NET_2_0
+ [ComVisible (false)]
public static FieldInfo GetFieldFromHandle (RuntimeFieldHandle handle, RuntimeTypeHandle declaringType)
{
- return internal_from_handle_type (handle.Value, declaringType.Value);
+ if (handle.Value == IntPtr.Zero)
+ throw new ArgumentException ("The handle is invalid.");
+ FieldInfo fi = internal_from_handle_type (handle.Value, declaringType.Value);
+ if (fi == null)
+ throw new ArgumentException ("The field handle and the type handle are incompatible.");
+ return fi;
}
-#endif
//
// Note: making this abstract imposes an implementation requirement
}
[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 ()
{
if (DeclaringType.IsExplicitLayout)
count ++;
- UnmanagedMarshal marshalAs = UMarshal;
+ MarshalAsAttribute marshalAs = get_marshal_info ();
if (marshalAs != null)
count ++;
if (DeclaringType.IsExplicitLayout)
attrs [count ++] = new FieldOffsetAttribute (GetFieldOffset ());
if (marshalAs != null)
- attrs [count ++] = marshalAs.ToMarshalAsAttribute ();
+ attrs [count ++] = marshalAs;
return attrs;
}
-#if NET_2_0 || BOOTSTRAP_NET_2_0
- [MonoTODO("Not implemented")]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern Type[] GetTypeModifiers (bool optional);
+
public virtual Type[] GetOptionalCustomModifiers () {
- throw new NotImplementedException ();
+ Type[] types = GetTypeModifiers (true);
+ if (types == null)
+ return Type.EmptyTypes;
+ return types;
}
- [MonoTODO("Not implemented")]
public virtual Type[] GetRequiredCustomModifiers () {
- throw new NotImplementedException ();
+ Type[] types = GetTypeModifiers (false);
+ if (types == null)
+ return Type.EmptyTypes;
+ return types;
}
public virtual object GetRawConstantValue ()
{
throw new NotSupportedException ("This non-CLS method is not implemented.");
}
-#endif
+
+ public override bool Equals (object obj)
+ {
+ return obj == (object) this;
+ }
+
+ public override int GetHashCode ()
+ {
+ return base.GetHashCode ();
+ }
+
+ public static bool operator == (FieldInfo left, FieldInfo 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 != (FieldInfo left, FieldInfo right)
+ {
+ if ((object)left == (object)right)
+ return false;
+ if ((object)left == null ^ (object)right == null)
+ return true;
+ return !left.Equals (right);
+ }
+
+ 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 ();
{
throw new NotImplementedException ();
}
+#endif
}
}