Updated with Xamarin copyrights
[mono.git] / mcs / mcs / assembly.cs
index c0806f54af34658f8ce3f7a33aa4e37702963caf..ef1ffb669468b9f07e1c0b4acf11b3a2bf4f733f 100644 (file)
@@ -6,7 +6,8 @@
 //   Marek Safar (marek.safar@gmail.com)
 //
 // Copyright 2001, 2002, 2003 Ximian, Inc.
-// Copyright 2004 Novell, Inc.
+// Copyright 2004-2011 Novell, Inc.
+// Copyright 2011 Xamarin Inc
 //
 
 
@@ -376,6 +377,12 @@ namespace Mono.CSharp
                                                a.FullName);
                                }
 
+                               var ci = a.Assembly.GetName ().CultureInfo;
+                               if (!ci.Equals (System.Globalization.CultureInfo.InvariantCulture)) {
+                                       Report.Warning (1607, 1, "Referenced assembly `{0}' has different culture setting of `{1}'",
+                                               a.Name, ci.Name);
+                               }
+
                                if (!a.IsFriendAssemblyTo (this))
                                        continue;
 
@@ -442,8 +449,12 @@ namespace Mono.CSharp
                        if (Compiler.Settings.GenerateDebugInfo) {
                                symbol_writer = new MonoSymbolWriter (file_name);
 
+                               // Register all source files with symbol writer
+                               foreach (var source in Compiler.SourceFiles) {
+                                       source.DefineSymbolInfo (symbol_writer);
+                               }
+
                                // TODO: global variables
-                               Location.DefineSymbolDocuments (symbol_writer);
                                SymbolWriter.symwriter = symbol_writer;
                        }
 
@@ -462,7 +473,7 @@ namespace Mono.CSharp
                                        var prop = module.PredefinedMembers.RuntimeCompatibilityWrapNonExceptionThrows.Get ();
                                        if (prop != null) {
                                                AttributeEncoder encoder = new AttributeEncoder ();
-                                               encoder.EncodeNamedPropertyArgument (prop, new BoolLiteral (Compiler.BuildinTypes, true, Location.Null));
+                                               encoder.EncodeNamedPropertyArgument (prop, new BoolLiteral (Compiler.BuiltinTypes, true, Location.Null));
                                                SetCustomAttribute (pa.Constructor, encoder.ToArray ());
                                        }
                                }
@@ -614,9 +625,9 @@ namespace Mono.CSharp
                                pos.Add (new Argument (req_min.GetConstant (null)));
 
                                Arguments named = new Arguments (1);
-                               named.Add (new NamedArgument ("SkipVerification", loc, new BoolLiteral (Compiler.BuildinTypes, true, loc)));
+                               named.Add (new NamedArgument ("SkipVerification", loc, new BoolLiteral (Compiler.BuiltinTypes, true, loc)));
 
-                               GlobalAttribute g = new GlobalAttribute (new NamespaceEntry (module, null, null, null), "assembly",
+                               Attribute g = new Attribute ("assembly",
                                        new MemberAccess (system_security_permissions, "SecurityPermissionAttribute"),
                                        new Arguments[] { pos, named }, loc, false);
                                g.AttachTo (module, module);
@@ -862,26 +873,24 @@ namespace Mono.CSharp
                        }
 
                        if (entry_point == null) {
-                               if (Compiler.Settings.MainClass != null) {
-                                       // TODO: Should use MemberCache
-                                       DeclSpace main_cont = module.GetDefinition (Compiler.Settings.MainClass) as DeclSpace;
-                                       if (main_cont == null) {
-                                               Report.Error (1555, "Could not find `{0}' specified for Main method", Compiler.Settings.MainClass);
+                               string main_class = Compiler.Settings.MainClass;
+                               if (main_class != null) {
+                                       // TODO: Handle dotted names
+                                       var texpr = module.GlobalRootNamespace.LookupType (module, main_class, 0, LookupMode.Probing, Location.Null);
+                                       if (texpr == null) {
+                                               Report.Error (1555, "Could not find `{0}' specified for Main method", main_class);
                                                return;
                                        }
 
-                                       if (!(main_cont is ClassOrStruct)) {
-                                               Report.Error (1556, "`{0}' specified for Main method must be a valid class or struct", Compiler.Settings.MainClass);
+                                       var mtype = texpr.Type.MemberDefinition as ClassOrStruct;
+                                       if (mtype == null) {
+                                               Report.Error (1556, "`{0}' specified for Main method must be a valid class or struct", main_class);
                                                return;
                                        }
 
-                                       Report.Error (1558, main_cont.Location, "`{0}' does not have a suitable static Main method", main_cont.GetSignatureForError ());
-                                       return;
-                               }
-
-                               if (Report.Errors == 0) {
+                                       Report.Error (1558, mtype.Location, "`{0}' does not have a suitable static Main method", mtype.GetSignatureForError ());
+                               } else {
                                        string pname = file_name == null ? name : Path.GetFileName (file_name);
-
                                        Report.Error (5001, "Program `{0}' does not contain a static `Main' method suitable for an entry point",
                                                pname);
                                }
@@ -991,7 +1000,7 @@ namespace Mono.CSharp
                public AssemblyAttributesPlaceholder (ModuleContainer parent, string outputName)
                        : base (parent, new MemberName (GetGeneratedName (outputName)), Modifiers.STATIC)
                {
-                       assembly = new Field (this, new TypeExpression (parent.Compiler.BuildinTypes.Object, Location), Modifiers.PUBLIC | Modifiers.STATIC,
+                       assembly = new Field (this, new TypeExpression (parent.Compiler.BuiltinTypes.Object, Location), Modifiers.PUBLIC | Modifiers.STATIC,
                                new MemberName (AssemblyFieldName), null);
 
                        AddField (assembly);