public virtual void Emit() { if (Compiler.Settings.Target == Target.Module) { module_target_attrs = new AssemblyAttributesPlaceholder(module, name); module_target_attrs.CreateContainer(); module_target_attrs.DefineContainer(); module_target_attrs.Define(); module.AddCompilerGeneratedClass(module_target_attrs); } else if (added_modules != null) { ReadModulesAssemblyAttributes(); } if (Compiler.Settings.GenerateDebugInfo) { symbol_writer = new MonoSymbolFile(); } module.EmitContainer(); if (module.HasExtensionMethod) { var pa = module.PredefinedAttributes.Extension; if (pa.IsDefined) { SetCustomAttribute(pa.Constructor, AttributeEncoder.Empty); } } if (!IsSatelliteAssembly) { if (!wrap_non_exception_throws_custom) { PredefinedAttribute pa = module.PredefinedAttributes.RuntimeCompatibility; if (pa.IsDefined && pa.ResolveBuilder()) { var prop = module.PredefinedMembers.RuntimeCompatibilityWrapNonExceptionThrows.Get(); if (prop != null) { AttributeEncoder encoder = new AttributeEncoder(); encoder.EncodeNamedPropertyArgument(prop, new BoolLiteral(Compiler.BuiltinTypes, true, Location.Null)); SetCustomAttribute(pa.Constructor, encoder.ToArray()); } } } if (declarative_security != null) { #if STATIC foreach (var entry in declarative_security) { Builder.__AddDeclarativeSecurity(entry); } #else throw new NotSupportedException("Assembly-level security"); #endif } } CheckReferencesPublicToken(); SetEntryPoint(); }
public virtual void Emit() { if (Compiler.Settings.Target == Target.Module) { module_target_attrs = new AssemblyAttributesPlaceholder(module, name); module_target_attrs.CreateType(); module_target_attrs.DefineType(); module_target_attrs.Define(); module.AddCompilerGeneratedClass(module_target_attrs); } else if (added_modules != null) { ReadModulesAssemblyAttributes(); } 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; } module.Emit(); if (module.HasExtensionMethod) { var pa = module.PredefinedAttributes.Extension; if (pa.IsDefined) { SetCustomAttribute(pa.Constructor, AttributeEncoder.Empty); } } if (!wrap_non_exception_throws_custom) { PredefinedAttribute pa = module.PredefinedAttributes.RuntimeCompatibility; if (pa.IsDefined && pa.ResolveBuilder()) { var prop = module.PredefinedMembers.RuntimeCompatibilityWrapNonExceptionThrows.Get(); if (prop != null) { AttributeEncoder encoder = new AttributeEncoder(); encoder.EncodeNamedPropertyArgument(prop, new BoolLiteral(Compiler.BuiltinTypes, true, Location.Null)); SetCustomAttribute(pa.Constructor, encoder.ToArray()); } } } if (declarative_security != null) { #if STATIC foreach (var entry in declarative_security) { 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); #endif } CheckReferencesPublicToken(); SetEntryPoint(); }