// TODO: make it private and move all builder based methods here
public AssemblyBuilder Builder;
protected AssemblyBuilderExtension builder_extra;
- MonoSymbolWriter symbol_writer;
+ MonoSymbolFile symbol_writer;
bool is_cls_compliant;
bool wrap_non_exception_throws;
}
}
+ public MonoSymbolFile SymbolWriter {
+ get {
+ return symbol_writer;
+ }
+ }
+
#endregion
public void AddModule (ImportedModuleDefinition module)
{
if (Compiler.Settings.Target == Target.Module) {
module_target_attrs = new AssemblyAttributesPlaceholder (module, name);
- module_target_attrs.CreateType ();
- module_target_attrs.DefineType ();
+ module_target_attrs.CreateContainer ();
+ module_target_attrs.DefineContainer ();
module_target_attrs.Define ();
module.AddCompilerGeneratedClass (module_target_attrs);
} else if (added_modules != null) {
}
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
- SymbolWriter.symwriter = symbol_writer;
+ symbol_writer = new MonoSymbolFile ();
}
- module.Emit ();
+ module.EmitContainer ();
if (module.HasExtensionMethod) {
var pa = module.PredefinedAttributes.Extension;
Builder.__AddDeclarativeSecurity (entry);
}
#else
- var args = new PermissionSet[3];
- declarative_security.TryGetValue (SecurityAction.RequestMinimum, out args[0]);
- declarative_security.TryGetValue (SecurityAction.RequestOptional, out args[1]);
- declarative_security.TryGetValue (SecurityAction.RequestRefuse, out args[2]);
- builder_extra.AddPermissionRequests (args);
+ throw new NotSupportedException ("Assembly-level security");
#endif
}
new MemberAccess (system_security_permissions, "SecurityPermissionAttribute"),
new Arguments[] { pos, named }, loc, false);
g.AttachTo (module, module);
- var ctor = g.Resolve ();
- if (ctor != null) {
- g.ExtractSecurityPermissionSet (ctor, ref declarative_security);
+
+ // Disable no-location warnings (e.g. obsolete) for compiler generated attribute
+ Compiler.Report.DisableReporting ();
+ try {
+ var ctor = g.Resolve ();
+ if (ctor != null) {
+ g.ExtractSecurityPermissionSet (ctor, ref declarative_security);
+ }
+ } finally {
+ Compiler.Report.EnableReporting ();
}
}
public void Save ()
{
- PortableExecutableKinds pekind;
+ PortableExecutableKinds pekind = PortableExecutableKinds.ILOnly;
ImageFileMachine machine;
switch (Compiler.Settings.Platform) {
case Platform.X86:
- pekind = PortableExecutableKinds.Required32Bit | PortableExecutableKinds.ILOnly;
+ pekind |= PortableExecutableKinds.Required32Bit;
machine = ImageFileMachine.I386;
break;
case Platform.X64:
- pekind = PortableExecutableKinds.ILOnly;
+ pekind |= PortableExecutableKinds.PE32Plus;
machine = ImageFileMachine.AMD64;
break;
case Platform.IA64:
- pekind = PortableExecutableKinds.ILOnly;
machine = ImageFileMachine.IA64;
break;
+ case Platform.AnyCPU32Preferred:
+#if STATIC
+ pekind |= PortableExecutableKinds.Preferred32Bit;
+ machine = ImageFileMachine.I386;
+ break;
+#else
+ throw new NotSupportedException ();
+#endif
+ case Platform.Arm:
+#if STATIC
+ machine = ImageFileMachine.ARM;
+ break;
+#else
+ throw new NotSupportedException ();
+#endif
case Platform.AnyCPU:
default:
- pekind = PortableExecutableKinds.ILOnly;
machine = ImageFileMachine.I386;
break;
}
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));
+
+ var filename = file_name + ".mdb";
+ try {
+ // We mmap the file, so unlink the previous version since it may be in use
+ File.Delete (filename);
+ } catch {
+ // We can safely ignore
+ }
+
+ module.WriteDebugSymbol (symbol_writer);
+
+ using (FileStream fs = new FileStream (filename, FileMode.Create, FileAccess.Write)) {
+ symbol_writer.CreateSymbolFile (module.Builder.ModuleVersionId, fs);
+ }
+
Compiler.TimeReporter.Stop (TimeReporter.TimerType.DebugSave);
}
}
//
// A placeholder class for assembly attributes when emitting module
//
- class AssemblyAttributesPlaceholder : CompilerGeneratedClass
+ class AssemblyAttributesPlaceholder : CompilerGeneratedContainer
{
static readonly string TypeNamePrefix = "<$AssemblyAttributes${0}>";
public static readonly string AssemblyFieldName = "attributes";
Field assembly;
public AssemblyAttributesPlaceholder (ModuleContainer parent, string outputName)
- : base (parent, new MemberName (GetGeneratedName (outputName)), Modifiers.STATIC)
+ : base (parent, new MemberName (GetGeneratedName (outputName)), Modifiers.STATIC | Modifiers.INTERNAL)
{
assembly = new Field (this, new TypeExpression (parent.Compiler.BuiltinTypes.Object, Location), Modifiers.PUBLIC | Modifiers.STATIC,
new MemberName (AssemblyFieldName), null);