// 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
//
string assembly_name = a.GetString ();
if (assembly_name.Length == 0)
return;
-
- AssemblyName aname = null;
- try {
- aname = new AssemblyName (assembly_name);
- } catch (Exception) {
+#if STATIC
+ ParsedAssemblyName aname;
+ ParseAssemblyResult r = Fusion.ParseAssemblyName (assembly_name, out aname);
+ if (r != ParseAssemblyResult.OK) {
Report.Warning (1700, 3, a.Location, "Assembly reference `{0}' is invalid and cannot be resolved",
assembly_name);
return;
}
- if (aname.Version != null || aname.CultureInfo != null || aname.ProcessorArchitecture != ProcessorArchitecture.None) {
+ if (aname.Version != null || aname.Culture != null || aname.ProcessorArchitecture != ProcessorArchitecture.None) {
Report.Error (1725, a.Location,
"Friend assembly reference `{0}' is invalid. InternalsVisibleTo declarations cannot have a version, culture or processor architecture specified",
assembly_name);
return;
}
- // TODO: GetPublicKey () does not work on .NET when AssemblyName is constructed from a string
- if (public_key != null && aname.GetPublicKey () == null) {
+ if (public_key != null && !aname.HasPublicKey) {
Report.Error (1726, a.Location,
"Friend assembly reference `{0}' is invalid. Strong named assemblies must specify a public key in their InternalsVisibleTo declarations",
assembly_name);
return;
}
+#endif
} else if (a.Type == pa.RuntimeCompatibility) {
wrap_non_exception_throws_custom = true;
} else if (a.Type == pa.AssemblyFileVersion) {
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;
Arguments named = new Arguments (1);
named.Add (new NamedArgument ("SkipVerification", loc, new BoolLiteral (Compiler.BuiltinTypes, true, loc)));
- GlobalAttribute g = new GlobalAttribute ("assembly",
+ Attribute g = new Attribute ("assembly",
new MemberAccess (system_security_permissions, "SecurityPermissionAttribute"),
new Arguments[] { pos, named }, loc, false);
g.AttachTo (module, module);
Compiler.TimeReporter.Stop (TimeReporter.TimerType.OutputSave);
// Save debug symbols file
- if (symbol_writer != null) {
+ if (symbol_writer != null && Compiler.Report.Errors == 0) {
// TODO: it should run in parallel
Compiler.TimeReporter.Start (TimeReporter.TimerType.DebugSave);
symbol_writer.WriteSymbolFile (SymbolWriter.GetGuid (module.Builder));
}
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 abstract bool HasObjectType (T assembly);
protected abstract string[] GetDefaultReferences ();
- public abstract T LoadAssemblyFile (string fileName);
- public abstract T LoadAssemblyDefault (string assembly);
+ public abstract T LoadAssemblyFile (string fileName, bool isImplicitReference);
public abstract void LoadReferences (ModuleContainer module);
protected void Error_FileNotFound (string fileName)
// Load mscorlib.dll as the first
//
if (module.Compiler.Settings.StdLib) {
- corlib_assembly = LoadAssemblyDefault ("mscorlib.dll");
+ corlib_assembly = LoadAssemblyFile ("mscorlib.dll", true);
} else {
corlib_assembly = default (T);
}
T a;
foreach (string r in module.Compiler.Settings.AssemblyReferences) {
- a = LoadAssemblyFile (r);
+ a = LoadAssemblyFile (r, false);
if (a == null || EqualityComparer<T>.Default.Equals (a, corlib_assembly))
continue;
}
foreach (var entry in module.Compiler.Settings.AssemblyReferencesAliases) {
- a = LoadAssemblyFile (entry.Item2);
+ a = LoadAssemblyFile (entry.Item2, false);
if (a == null)
continue;
if (compiler.Settings.LoadDefaultReferences) {
foreach (string r in GetDefaultReferences ()) {
- a = LoadAssemblyDefault (r);
+ a = LoadAssemblyFile (r, true);
if (a == null)
continue;