Merge pull request #1659 from alexanderkyte/stringbuilder-referencesource
[mono.git] / mcs / class / corlib / System / RuntimeFieldHandle.cs
index c796f588f415088aa6ef92cb7c941dca93b35677..8c552b66a3c405cca6d9a6b1c82e202fed3b5170 100644 (file)
 using System.Reflection;
 using System.Runtime.Serialization;
 using System.Runtime.InteropServices;
-
-#if NET_2_0
 using System.Runtime.ConstrainedExecution;
-#endif
+using System.Runtime.CompilerServices;
 
 namespace System
 {
-#if NET_2_0
        [ComVisible (true)]
-#endif
-       [MonoTODO ("Serialization needs tests")]
        [Serializable]
        public struct RuntimeFieldHandle : ISerializable
        {
@@ -77,10 +72,12 @@ namespace System
                        if (info == null)
                                throw new ArgumentNullException ("info");
 
+                       if (value == IntPtr.Zero)
+                               throw new SerializationException ("Object fields may not be properly initialized");
+
                        info.AddValue ("FieldObj", (MonoField) FieldInfo.GetFieldFromHandle (this), typeof (MonoField));
                }
 
-#if NET_2_0
                [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
                public override bool Equals (object obj)
                {
@@ -110,6 +107,21 @@ namespace System
                {
                        return !left.Equals (right);
                }
-#endif
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               static extern void SetValueInternal (FieldInfo fi, object obj, object value);
+
+               internal static void SetValue (RtFieldInfo field, Object obj, Object value, RuntimeType fieldType, FieldAttributes fieldAttr, RuntimeType declaringType, ref bool domainInitialized)
+               {
+                       SetValueInternal (field, obj, value);
+               }
+
+               unsafe internal static Object GetValueDirect (RtFieldInfo field, RuntimeType fieldType, void *pTypedRef, RuntimeType contextType)
+               {
+                       throw new NotImplementedException ("GetValueDirect");
+               }
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               static unsafe extern internal void SetValueDirect (RtFieldInfo field, RuntimeType fieldType, void* pTypedRef, Object value, RuntimeType contextType);
        }
 }