Merge pull request #487 from mayerwin/patch-1
[mono.git] / mcs / class / corlib / System.Reflection.Emit / ConstructorBuilder.cs
index bc119495e27cc3774f09709b5e26d9fd611cc223..2391dc8be2cae1cf3696be5be1e14be8c5b007e4 100644 (file)
@@ -30,6 +30,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if !FULL_AOT_RUNTIME
 using System;
 using System.Reflection;
 using System.Reflection.Emit;
@@ -41,11 +42,10 @@ using System.Diagnostics.SymbolStore;
 
 namespace System.Reflection.Emit {
 
-#if NET_2_0
        [ComVisible (true)]
        [ComDefaultInterface (typeof (_ConstructorBuilder))]
-#endif
        [ClassInterface (ClassInterfaceType.None)]
+       [StructLayout (LayoutKind.Sequential)]
        public sealed class ConstructorBuilder : ConstructorInfo, _ConstructorBuilder {
        
 #pragma warning disable 169, 414
@@ -85,14 +85,13 @@ namespace System.Reflection.Emit {
                        ((ModuleBuilder) tb.Module).RegisterToken (this, GetToken ().Token);
                }
 
-#if NET_2_0
                [MonoTODO]
                public override CallingConventions CallingConvention {
                        get {
                                return call_conv;
                        }
                }
-#endif
+
                public bool InitLocals {
                        get {
                                return init_locals;
@@ -115,7 +114,7 @@ namespace System.Reflection.Emit {
 
                public override ParameterInfo[] GetParameters ()
                {
-                       if (!type.is_created && !IsCompilerContext)
+                       if (!type.is_created)
                                throw not_created ();
 
                        return GetParametersInternal ();
@@ -141,6 +140,10 @@ namespace System.Reflection.Emit {
                        
                        return parameters.Length;
                }
+
+               internal override Type GetParameterType (int pos) {
+                       return parameters [pos];
+               }
                
                public override Object Invoke (Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
                {
@@ -176,6 +179,9 @@ namespace System.Reflection.Emit {
                        }
                }
 
+#if NET_4_0
+               [Obsolete]
+#endif
                public Type ReturnType {
                        get {
                                return null;
@@ -245,23 +251,12 @@ namespace System.Reflection.Emit {
 
                public override object [] GetCustomAttributes (bool inherit)
                {
-                       /*
-                        * On MS.NET, this always returns not_supported, but we can't do this
-                        * since there would be no way to obtain custom attributes of 
-                        * dynamically created ctors.
-                        */
-                       if (type.is_created && IsCompilerContext)
-                               return MonoCustomAttrs.GetCustomAttributes (this, inherit);
-                       else
-                               throw not_supported ();
+                       throw not_supported ();
                }
 
                public override object [] GetCustomAttributes (Type attributeType, bool inherit)
                {
-                       if (type.is_created && IsCompilerContext)
-                               return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
-                       else
-                               throw not_supported ();
+                       throw not_supported ();
                }
 
                public ILGenerator GetILGenerator ()
@@ -269,12 +264,7 @@ namespace System.Reflection.Emit {
                        return GetILGenerator (64);
                }
 
-#if NET_2_0
-               public
-#else
-               internal
-#endif
-               ILGenerator GetILGenerator (int streamSize)
+               public ILGenerator GetILGenerator (int streamSize)
                {
                        if (ilgen != null)
                                return ilgen;
@@ -307,9 +297,7 @@ namespace System.Reflection.Emit {
                        }
                }
 
-#if NET_2_0
                [ComVisible (true)]
-#endif
                public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
                {
                        if (con == null)
@@ -345,13 +333,11 @@ namespace System.Reflection.Emit {
                                throw not_after_created ();
                }
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
                public override Module Module {
                        get {
                                return base.Module;
                        }
                }
-#endif
 
                public override string ToString ()
                {
@@ -361,7 +347,7 @@ namespace System.Reflection.Emit {
                internal void fixup ()
                {
                        if (((attrs & (MethodAttributes.Abstract | MethodAttributes.PinvokeImpl)) == 0) && ((iattrs & (MethodImplAttributes.Runtime | MethodImplAttributes.InternalCall)) == 0)) {
-                       if ((ilgen == null) || (ILGenerator.Mono_GetCurrentOffset (ilgen) == 0))
+                       if ((ilgen == null) || (ilgen.ILOffset == 0))
                                throw new InvalidOperationException ("Method '" + Name + "' does not have a method body.");
                        }
                        if (ilgen != null)
@@ -384,14 +370,6 @@ namespace System.Reflection.Emit {
                        return type.get_next_table_index (obj, table, inc);
                }
 
-               private bool IsCompilerContext {
-                       get {
-                               ModuleBuilder mb = (ModuleBuilder) TypeBuilder.Module;
-                               AssemblyBuilder ab = (AssemblyBuilder) mb.Assembly;
-                               return ab.IsCompilerContext;
-                       }
-               }
-
                private void RejectIfCreated ()
                {
                        if (type.is_created)
@@ -410,11 +388,7 @@ namespace System.Reflection.Emit {
 
                private Exception not_created ()
                {
-#if NET_2_0
                        return new NotSupportedException ("The type is not yet created.");
-#else
-                       return new InvalidOperationException ("The type is not yet created.");
-#endif
                }
 
                void _ConstructorBuilder.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
@@ -438,3 +412,4 @@ namespace System.Reflection.Emit {
                }
        }
 }
+#endif