in ILRepack/Steps/AttributesRepackStep.cs [47:80]
public void Perform()
{
var targetAssemblyDefinition = _repackContext.TargetAssemblyDefinition;
var targetAssemblyMainModule = _repackContext.TargetAssemblyMainModule;
if (_options.CopyAttributes)
{
foreach (var ass in _repackContext.MergedAssemblies)
{
_repackCopier.CopyCustomAttributes(ass.CustomAttributes, targetAssemblyDefinition.CustomAttributes, _options.AllowMultipleAssemblyLevelAttributes, null);
}
foreach (var mod in _repackContext.MergedAssemblies.SelectMany(x => x.Modules))
{
_repackCopier.CopyCustomAttributes(mod.CustomAttributes, targetAssemblyMainModule.CustomAttributes, _options.AllowMultipleAssemblyLevelAttributes, null);
}
CleanupAttributes();
RemoveAttributes();
}
else if (_options.AttributeFile != null)
{
AssemblyDefinition attributeAsm = AssemblyDefinition.ReadAssembly(_options.AttributeFile, new ReaderParameters(ReadingMode.Immediate) { AssemblyResolver = _repackContext.GlobalAssemblyResolver });
_repackCopier.CopyCustomAttributes(attributeAsm.CustomAttributes, targetAssemblyDefinition.CustomAttributes, null);
_repackCopier.CopyCustomAttributes(attributeAsm.CustomAttributes, targetAssemblyMainModule.CustomAttributes, null);
// TODO: should copy Win32 resources, too
}
else
{
_repackCopier.CopyCustomAttributes(_repackContext.PrimaryAssemblyDefinition.CustomAttributes, targetAssemblyDefinition.CustomAttributes, null);
_repackCopier.CopyCustomAttributes(_repackContext.PrimaryAssemblyMainModule.CustomAttributes, targetAssemblyMainModule.CustomAttributes, null);
// TODO: should copy Win32 resources, too
RemoveAttributes();
}
_repackCopier.CopySecurityDeclarations(_repackContext.PrimaryAssemblyDefinition.SecurityDeclarations, targetAssemblyDefinition.SecurityDeclarations, null);
}