using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
namespace System.Reflection {
-
- internal class MonoField : FieldInfo {
+
+ [Serializable]
+ internal class MonoField : FieldInfo, ISerializable {
internal IntPtr klass;
internal RuntimeFieldHandle fhandle;
string name;
{
if (!IsStatic && obj == null)
throw new TargetException ("Non-static field requires a target");
+ if (!IsLiteral)
+ CheckGeneric ();
return GetValueInternal (obj);
}
throw new FieldAccessException ("Cannot set a constant field");
if (binder == null)
binder = Binder.DefaultBinder;
+ CheckGeneric ();
if (val != null) {
object newVal;
newVal = binder.ChangeType (val, type, culture);
field.fhandle = fhandle;
return field;
}
+
+ // ISerializable
+ public void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ MemberInfoSerializationHolder.Serialize (info, Name, ReflectedType,
+ ToString(), MemberTypes.Field);
+ }
+
+#if NET_2_0
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ public override extern object GetRawConstantValue ();
+#endif
+
+ void CheckGeneric () {
+#if NET_2_0
+ if (DeclaringType.ContainsGenericParameters)
+ throw new InvalidOperationException ("Late bound operations cannot be performed on fields with types for which Type.ContainsGenericParameters is true.");
+#endif
+ }
}
}