// 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
//
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;
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;
}
if (!wrap_non_exception_throws_custom) {
PredefinedAttribute pa = module.PredefinedAttributes.RuntimeCompatibility;
if (pa.IsDefined && pa.ResolveBuilder ()) {
- var prop = pa.GetProperty ("WrapNonExceptionThrows", TypeManager.bool_type, Location.Null);
+ var prop = module.PredefinedMembers.RuntimeCompatibilityWrapNonExceptionThrows.Get ();
if (prop != null) {
AttributeEncoder encoder = new AttributeEncoder ();
- encoder.EncodeNamedPropertyArgument (prop, new BoolLiteral (true, Location.Null));
+ encoder.EncodeNamedPropertyArgument (prop, new BoolLiteral (Compiler.BuiltinTypes, true, Location.Null));
SetCustomAttribute (pa.Constructor, encoder.ToArray ());
}
}
MemberAccess system_security_permissions = new MemberAccess (new MemberAccess (
new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Security", loc), "Permissions", loc);
- var req_min = (ConstSpec) module.PredefinedTypes.SecurityAction.GetField ("RequestMinimum", module.PredefinedTypes.SecurityAction.TypeSpec, loc);
+ var req_min = module.PredefinedMembers.SecurityActionRequestMinimum.Resolve (loc);
Arguments pos = new Arguments (1);
pos.Add (new Argument (req_min.GetConstant (null)));
Arguments named = new Arguments (1);
- named.Add (new NamedArgument ("SkipVerification", loc, new BoolLiteral (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);
}
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);
}
public AssemblyAttributesPlaceholder (ModuleContainer parent, string outputName)
: base (parent, new MemberName (GetGeneratedName (outputName)), Modifiers.STATIC)
{
- assembly = new Field (this, new TypeExpression (TypeManager.object_type, 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);
protected readonly CompilerContext compiler;
protected readonly List<string> paths;
- readonly string[] default_references;
public AssemblyReferencesLoader (CompilerContext compiler)
{
this.compiler = compiler;
- if (compiler.Settings.LoadDefaultReferences)
- default_references = GetDefaultReferences ();
- else
- default_references = new string[0];
-
paths = new List<string> ();
paths.AddRange (compiler.Settings.ReferencesLookupPaths);
paths.Add (Directory.GetCurrentDirectory ());
}
T a;
- foreach (string r in default_references) {
- a = LoadAssemblyDefault (r);
- if (a != null)
- loaded.Add (Tuple.Create (module.GlobalRootNamespace, a));
- }
-
foreach (string r in module.Compiler.Settings.AssemblyReferences) {
a = LoadAssemblyFile (r);
if (a == null || EqualityComparer<T>.Default.Equals (a, corlib_assembly))
loaded.Add (key);
}
+ if (compiler.Settings.LoadDefaultReferences) {
+ foreach (string r in GetDefaultReferences ()) {
+ a = LoadAssemblyDefault (r);
+ if (a == null)
+ continue;
+
+ var key = Tuple.Create (module.GlobalRootNamespace, a);
+ if (loaded.Contains (key))
+ continue;
+
+ loaded.Add (key);
+ }
+ }
+
compiler.TimeReporter.Stop (TimeReporter.TimerType.ReferencesLoading);
}
}