X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem.Reflection%2FMonoField.cs;h=2b3894dd0ff693c5270ff53f025db433238acc20;hb=4323fbeaebf249f016dfdd6dc9b3b52a515f87c4;hp=48247af850251151e837a4b4c50c320b4ddefa2c;hpb=9d61782c6e2392d7ceec2006b35be582598a70ae;p=mono.git diff --git a/mcs/class/corlib/System.Reflection/MonoField.cs b/mcs/class/corlib/System.Reflection/MonoField.cs index 48247af8502..2b3894dd0ff 100644 --- a/mcs/class/corlib/System.Reflection/MonoField.cs +++ b/mcs/class/corlib/System.Reflection/MonoField.cs @@ -36,10 +36,12 @@ using System; 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; @@ -103,6 +105,7 @@ namespace System.Reflection { { if (!IsStatic && obj == null) throw new TargetException ("Non-static field requires a target"); + CheckGeneric (); return GetValueInternal (obj); } @@ -121,6 +124,7 @@ namespace System.Reflection { 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); @@ -141,5 +145,24 @@ namespace System.Reflection { 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 + } } }