Merge pull request #409 from Alkarex/patch-1
[mono.git] / mcs / class / corlib / System.Reflection.Emit / DynamicMethod.cs
index 5d4bda20252c4df3103c26a20914780a4f4beff9..931573d5449459c3860e103b5dab2811d820ee2c 100644 (file)
@@ -31,6 +31,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if !FULL_AOT_RUNTIME
 
 using System;
 using System.Reflection;
@@ -42,9 +43,10 @@ using System.Runtime.InteropServices;
 namespace System.Reflection.Emit {
 
        [ComVisible (true)]
+       [StructLayout (LayoutKind.Sequential)]
        public sealed class DynamicMethod : MethodInfo {
 
-#pragma warning disable 169, 414
+#pragma warning disable 169, 414, 649
                #region Sync with reflection.h
                private RuntimeMethodHandle mhandle;
                private string name;
@@ -61,7 +63,7 @@ namespace System.Reflection.Emit {
                private IntPtr referenced_by;
                private Type owner;
                #endregion
-#pragma warning restore 169, 414
+#pragma warning restore 169, 414, 649
                
                private Delegate deleg;
                private MonoMethod method;
@@ -111,9 +113,12 @@ namespace System.Reflection.Emit {
                                        if (parameterTypes [i] == null)
                                                throw new ArgumentException ("Parameter " + i + " is null", "parameterTypes");
                        }
+                       if (owner != null && (owner.IsArray || owner.IsInterface)) {
+                               throw new ArgumentException ("Owner can't be an array or an interface.");
+                       }
 
                        if (m == null)
-                               m = AnonHostModuleHolder.anon_host_module;
+                               m = AnonHostModuleHolder.AnonHostModule;
 
                        this.name = name;
                        this.attributes = attributes | MethodAttributes.Static;
@@ -411,6 +416,12 @@ namespace System.Reflection.Emit {
 
                                anon_host_module = ab.GetManifestModule ();
                        }
+
+                       public static Module AnonHostModule {
+                               get {
+                                       return anon_host_module;
+                               }
+                       }
                }
        }
 
@@ -440,3 +451,4 @@ namespace System.Reflection.Emit {
        }
 }
 
+#endif