Merge pull request #819 from brendanzagaeski/patch-1
[mono.git] / mcs / mcs / assembly.cs
index b2e4e9a20181b84e86a02b000a20ffed083fdd32..6c99245480b93f6766af3adb8b86f5beddb78c0c 100644 (file)
@@ -54,6 +54,7 @@ namespace Mono.CSharp
                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;
@@ -366,6 +367,8 @@ namespace Mono.CSharp
                                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);
@@ -473,6 +476,17 @@ namespace Mono.CSharp
                        }
 
                        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 ()) {
@@ -919,7 +933,7 @@ namespace Mono.CSharp
                                                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;
@@ -1110,13 +1124,13 @@ namespace Mono.CSharp
                }
        }
 
-       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;