SetCustomAttribute() public method

public SetCustomAttribute ( System customBuilder ) : void
customBuilder System
return void
Esempio n. 1
0
        void SetUpAssembly()
        {
            var outputFile = BuildOutputAssemblyName();
            var asmName = CreateAssemblyName(outputFile);
            var assemblyBuilderAccess = GetAssemblyBuilderAccess();
            var targetDirectory = GetTargetDirectory(outputFile);
            _asmBuilder = string.IsNullOrEmpty(targetDirectory)
                ? AppDomain.CurrentDomain.DefineDynamicAssembly(asmName, assemblyBuilderAccess)
                : AppDomain.CurrentDomain.DefineDynamicAssembly(asmName, assemblyBuilderAccess, targetDirectory);

            if (Parameters.Debug)
            {
                // ikvm tip:  Set DebuggableAttribute to assembly before
                // creating the module, to make sure Visual Studio (Whidbey)
                // picks up the attribute when debugging dynamically generated code.
                _asmBuilder.SetCustomAttribute(CreateDebuggableAttribute());
            }

            _asmBuilder.SetCustomAttribute(CreateRuntimeCompatibilityAttribute());
            _moduleBuilder = _asmBuilder.DefineDynamicModule(asmName.Name, Path.GetFileName(outputFile), Parameters.Debug);

            if (Parameters.Unsafe)
            {
                _asmBuilder.SetCustomAttribute(CreateSecurityPermissionAttribute("SkipVerification"));
                _moduleBuilder.SetCustomAttribute(CreateUnverifiableCodeAttribute());
            }

            _sreResourceService = new SREResourceService (_asmBuilder, _moduleBuilder);
            ContextAnnotations.SetAssemblyBuilder(Context, _asmBuilder);

            Context.GeneratedAssemblyFileName = outputFile;
        }
Esempio n. 2
0
 private void EmitCustomAttributes(ModuleBuilder moduleBuilder, IEnumerable<Cci.ICustomAttribute> attributes)
 {
     foreach (var attribute in attributes)
     {
         moduleBuilder.SetCustomAttribute(CreateCustomAttributeBuilder(attribute));
     }
 }