Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
[mono.git] / mcs / class / corlib / System.Reflection.Emit / FieldBuilder.cs
index 8b4f452e27e590741c25b7532e19fdef21d6dbb3..053d8c831e4d05ea750b5b98b6324e0bb84d254f 100644 (file)
@@ -31,6 +31,7 @@
 // (C) 2001-2002 Ximian, Inc.  http://www.ximian.com
 //
 
+#if !FULL_AOT_RUNTIME
 using System;
 using System.Reflection;
 using System.Reflection.Emit;
@@ -39,11 +40,10 @@ using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 namespace System.Reflection.Emit {
-#if NET_2_0
        [ComVisible (true)]
        [ComDefaultInterface (typeof (_FieldBuilder))]
-#endif
        [ClassInterface (ClassInterfaceType.None)]
+       [StructLayout (LayoutKind.Sequential)]
        public sealed class FieldBuilder : FieldInfo, _FieldBuilder {
        
 #pragma warning disable 169, 414
@@ -75,6 +75,8 @@ namespace System.Reflection.Emit {
                        offset = -1;
                        typeb = tb;
                        table_idx = tb.get_next_table_index (this, 0x04, true);
+
+                       ((ModuleBuilder) tb.Module).RegisterToken (this, GetToken ().Token);
                }
 
                public override FieldAttributes Attributes {
@@ -165,11 +167,9 @@ namespace System.Reflection.Emit {
                        } else if (attrname == "System.NonSerializedAttribute") {
                                attrs |= FieldAttributes.NotSerialized;
                                return;
-#if NET_2_0
                        } else if (attrname == "System.Runtime.CompilerServices.SpecialNameAttribute") {
                                attrs |= FieldAttributes.SpecialName;
                                return;
-#endif
                        } else if (attrname == "System.Runtime.InteropServices.MarshalAsAttribute") {
                                attrs |= FieldAttributes.HasFieldMarshal;
                                marshal_info = CustomAttributeBuilder.get_umarshal (customBuilder, true);
@@ -187,17 +187,13 @@ namespace System.Reflection.Emit {
                        }
                }
 
-#if NET_2_0
                [ComVisible (true)]
-#endif
                public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
                        RejectIfCreated ();
                        SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
                }
 
-#if NET_2_0
                [Obsolete ("An alternate API is available: Emit the MarshalAs custom attribute instead.")]
-#endif
                public void SetMarshal( UnmanagedMarshal unmanagedMarshal) {
                        RejectIfCreated ();
                        marshal_info = unmanagedMarshal;
@@ -213,12 +209,6 @@ namespace System.Reflection.Emit {
                        throw CreateNotSupportedException ();
                }
 
-               internal override UnmanagedMarshal UMarshal {
-                       get {
-                               return marshal_info;
-                       }
-               }
-
                private Exception CreateNotSupportedException ()
                {
                        return new NotSupportedException ("The invoked member is not supported in a dynamic module.");
@@ -230,13 +220,11 @@ namespace System.Reflection.Emit {
                                throw new InvalidOperationException ("Unable to change after type has been created.");
                }
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
                public override Module Module {
                        get {
                                return base.Module;
                        }
                }
-#endif
 
                void _FieldBuilder.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
                {
@@ -260,3 +248,4 @@ namespace System.Reflection.Emit {
        }
 }
 
+#endif