//
// Copyright 2001, 2002, 2003 Ximian, Inc.
// Copyright 2004-2011 Novell, Inc.
-// Copyright 2011 Xamarin Inc
+// Copyright 2011-2013 Xamarin Inc
//
bool is_cls_compliant;
bool wrap_non_exception_throws;
bool wrap_non_exception_throws_custom;
+ bool has_user_debuggable;
protected ModuleContainer module;
readonly string name;
Dictionary<ITypeDefinition, Attribute> emitted_forwarders;
AssemblyAttributesPlaceholder module_target_attrs;
+ // Win32 version info values
+ string vi_product, vi_product_version, vi_company, vi_copyright, vi_trademark;
+
protected AssemblyDefinition (ModuleContainer module, string name)
{
this.module = module;
} else if (a.Type == pa.RuntimeCompatibility) {
wrap_non_exception_throws_custom = true;
} else if (a.Type == pa.AssemblyFileVersion) {
- string value = a.GetString ();
- if (string.IsNullOrEmpty (value) || IsValidAssemblyVersion (value, false) == null) {
+ vi_product_version = a.GetString ();
+ if (string.IsNullOrEmpty (vi_product_version) || IsValidAssemblyVersion (vi_product_version, false) == null) {
Report.Warning (1607, 1, a.Location, "The version number `{0}' specified for `{1}' is invalid",
- value, a.Name);
+ vi_product_version, a.Name);
return;
}
+ } else if (a.Type == pa.AssemblyProduct) {
+ vi_product = a.GetString ();
+ } else if (a.Type == pa.AssemblyCompany) {
+ vi_company = a.GetString ();
+ } else if (a.Type == pa.AssemblyDescription) {
+ // TODO: Needs extra api
+ } else if (a.Type == pa.AssemblyCopyright) {
+ vi_copyright = a.GetString ();
+ } else if (a.Type == pa.AssemblyTrademark) {
+ vi_trademark = a.GetString ();
+ } else if (a.Type == pa.Debuggable) {
+ has_user_debuggable = true;
}
-
SetCustomAttribute (ctor, cdata);
}
}
if (!IsSatelliteAssembly) {
+ if (!has_user_debuggable && Compiler.Settings.GenerateDebugInfo) {
+ var pa = module.PredefinedAttributes.Debuggable;
+ if (pa.IsDefined) {
+ var modes = System.Diagnostics.DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints;
+ if (!Compiler.Settings.Optimize)
+ modes |= System.Diagnostics.DebuggableAttribute.DebuggingModes.DisableOptimizations;
+
+ pa.EmitAttribute (Builder, modes);
+ }
+ }
+
if (!wrap_non_exception_throws_custom) {
PredefinedAttribute pa = module.PredefinedAttributes.RuntimeCompatibility;
if (pa.IsDefined && pa.ResolveBuilder ()) {
if (Compiler.Settings.Win32ResourceFile != null) {
Builder.DefineUnmanagedResource (Compiler.Settings.Win32ResourceFile);
} else {
- Builder.DefineVersionInfoResource ();
+ Builder.DefineVersionInfoResource (vi_product, vi_product_version, vi_company, vi_copyright, vi_trademark);
}
if (Compiler.Settings.Win32IconFile != null) {
return;
}
- var mtype = texpr.Type.MemberDefinition as ClassOrStruct;
+ var mtype = texpr.MemberDefinition as ClassOrStruct;
if (mtype == null) {
Report.Error (1556, "`{0}' specified for Main method must be a valid class or struct", main_class);
return;
}
}
- abstract class AssemblyReferencesLoader<T>
+ abstract class AssemblyReferencesLoader<T> where T : class
{
protected readonly CompilerContext compiler;
protected readonly List<string> paths;
- public AssemblyReferencesLoader (CompilerContext compiler)
+ protected AssemblyReferencesLoader (CompilerContext compiler)
{
this.compiler = compiler;
if (loaded.Contains (key))
continue;
- // A corlib assembly is the first assembly which contains System.Object
- if (corlib_assembly == null && HasObjectType (a)) {
- corlib_assembly = a;
- continue;
- }
-
loaded.Add (key);
}
+ if (corlib_assembly == null) {
+ //
+ // Requires second pass because HasObjectType can trigger assembly load event
+ //
+ for (int i = 0; i < loaded.Count; ++i) {
+ var assembly = loaded [i];
+
+ //
+ // corlib assembly is the first referenced assembly which contains System.Object
+ //
+ if (HasObjectType (assembly.Item2)) {
+ corlib_assembly = assembly.Item2;
+ loaded.RemoveAt (i);
+ break;
+ }
+ }
+ }
+
foreach (var entry in module.Compiler.Settings.AssemblyReferencesAliases) {
a = LoadAssemblyFile (entry.Item2, false);
if (a == null)