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);
}
}
default_references.Add ("System.dll");
default_references.Add ("System.Xml.dll");
+ default_references.Add ("System.Core.dll");
- if (compiler.Settings.Version > LanguageVersion.ISO_2)
- default_references.Add ("System.Core.dll");
- if (compiler.Settings.Version > LanguageVersion.V_3)
+ if (corlib != null && corlib.GetName ().Version.Major >= 4) {
default_references.Add ("Microsoft.CSharp.dll");
+ }
return default_references.ToArray ();
}