Merge pull request #3120 from esdrubal/syscall_details
[mono.git] / mcs / class / corlib / System.Reflection.Emit / AssemblyBuilder.cs
index 5493215a529e6890d10c94303b8023069a33e479..6a6fcd36f5abe114d6eaa3751587690b41811a6c 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.Resources;
@@ -265,13 +266,6 @@ namespace System.Reflection.Emit
                        if ((access & COMPILER_ACCESS) != 0)
                                throw new NotImplementedException ("COMPILER_ACCESS is no longer supperted, use a newer mcs.");
 
-#if MOONLIGHT
-                       // only "Run" is supported by Silverlight
-                       // however SMCS requires more than this but runs outside the CoreCLR sandbox
-                       if (SecurityManager.SecurityEnabled && (access != AssemblyBuilderAccess.Run))
-                               throw new ArgumentException ("access");
-#endif
-
                        if (!Enum.IsDefined (typeof (AssemblyBuilderAccess), access))
                                throw new ArgumentException (string.Format (CultureInfo.InvariantCulture,
                                        "Argument value {0} is not valid.", (int) access),
@@ -464,6 +458,14 @@ namespace System.Reflection.Emit
                }
 */
 
+               public static AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
+               {
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+
+                       return new AssemblyBuilder (name, null, access, false);
+               }
+
                public ModuleBuilder DefineDynamicModule (string name)
                {
                        return DefineDynamicModule (name, name, false, true);
@@ -576,7 +578,7 @@ namespace System.Reflection.Emit
                        if (resourceFileName.Length == 0)
                                throw new ArgumentException ("resourceFileName");
                        if (!File.Exists (resourceFileName) || Directory.Exists (resourceFileName))
-                               throw new FileNotFoundException ("File '" + resourceFileName + "' does not exists or is a directory.");
+                               throw new FileNotFoundException ("File '" + resourceFileName + "' does not exist or is a directory.");
                        if (native_resource != NativeResourceType.None)
                                throw new ArgumentException ("Native resource has already been defined.");
 
@@ -781,9 +783,7 @@ namespace System.Reflection.Emit
                internal bool IsRun {
                        get {
                                return access == (uint)AssemblyBuilderAccess.Run || access == (uint)AssemblyBuilderAccess.RunAndSave
-#if NET_4_0
                                         || access == (uint)AssemblyBuilderAccess.RunAndCollect
-#endif
                                ;
 
                        }
@@ -865,7 +865,7 @@ namespace System.Reflection.Emit
                         */
                        if ((entry_point != null) && entry_point.DeclaringType.Module != mainModule) {
                                Type[] paramTypes;
-                               if (entry_point.GetParameters ().Length == 1)
+                               if (entry_point.GetParametersCount () == 1)
                                        paramTypes = new Type [] { typeof (string) };
                                else
                                        paramTypes = Type.EmptyTypes;
@@ -1038,16 +1038,6 @@ namespace System.Reflection.Emit
                        return (str == "neutral" ? String.Empty : str);
                }
 
-               internal override AssemblyName UnprotectedGetName ()
-               {
-                       AssemblyName an = base.UnprotectedGetName ();
-                       if (sn != null) {
-                               an.SetPublicKey (sn.PublicKey);
-                               an.SetPublicKeyToken (sn.PublicKeyToken);
-                       }
-                       return an;
-               }
-
                /*Warning, @typeArguments must be a mscorlib internal array. So make a copy before passing it in*/
                internal Type MakeGenericType (Type gtd, Type[] typeArguments)
                {
@@ -1074,7 +1064,6 @@ namespace System.Reflection.Emit
                        throw new NotImplementedException ();
                }
 
-#if NET_4_0 || MOONLIGHT || MOBILE
                public override Type GetType (string name, bool throwOnError, bool ignoreCase)
                {
                        if (name == null)
@@ -1125,7 +1114,15 @@ namespace System.Reflection.Emit
 
                public override AssemblyName GetName (bool copiedName)
                {
-                       return base.GetName (copiedName);
+                       AssemblyName aname = new AssemblyName ();
+                       FillName (this, aname);
+
+                       if (sn != null) {
+                               aname.SetPublicKey (sn.PublicKey);
+                               aname.SetPublicKeyToken (sn.PublicKeyToken);
+                       }
+                       return aname;
+
                }
 
                [MonoTODO ("This always returns an empty array")]
@@ -1194,6 +1191,6 @@ namespace System.Reflection.Emit
                public override string FullName {
                        get { return base.FullName; }
                }
-#endif
        }
 }
+#endif