Merge pull request #5636 from BrzVlad/fix-xmm-scan
[mono.git] / mcs / class / corlib / System.Reflection.Emit / AssemblyBuilder.cs
index ed524bb7c1878e5d63985411be8a9bf3a9dfbe9b..9c642ffa0062445fd98db4fe2ef938197a3fade6 100644 (file)
@@ -257,6 +257,9 @@ namespace System.Reflection.Emit
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private static extern void basic_init (AssemblyBuilder ab);
 
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               static extern void UpdateNativeCustomAttributes (AssemblyBuilder ab);
+
                /* Keep this in sync with codegen.cs in mcs */
                private const AssemblyBuilderAccess COMPILER_ACCESS = (AssemblyBuilderAccess) 0x800;
 
@@ -468,7 +471,12 @@ namespace System.Reflection.Emit
 
                public static AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
                {
-                       throw new NotImplementedException ();
+                       var ab = DefineDynamicAssembly (name, access);
+                       foreach (var attr in  assemblyAttributes) {
+                               ab.SetCustomAttribute (attr);
+                       }
+
+                       return ab;
                }
 
                public ModuleBuilder DefineDynamicModule (string name)
@@ -944,6 +952,12 @@ namespace System.Reflection.Emit
                                cattrs = new CustomAttributeBuilder [1];
                                cattrs [0] = customBuilder;
                        }
+
+                       /*
+                       Only update the native list of custom attributes if we're adding one that is known to change dynamic execution behavior.
+                       */
+                       if (customBuilder.Ctor != null && customBuilder.Ctor.DeclaringType == typeof (System.Runtime.CompilerServices.RuntimeCompatibilityAttribute))
+                               UpdateNativeCustomAttributes (this);
                }
 
                [ComVisible (true)]