in ILRepack/RepackImporter.cs [46:84]
public void Import(ExportedType type, Collection<ExportedType> col, ModuleDefinition module)
{
var scope = default(IMetadataScope);
// try to skip redirects to merged assemblies
if (type.Scope is AssemblyNameReference)
{
if (_repackContext.MergedAssemblies.Any(x => x.Name.Name == ((AssemblyNameReference)type.Scope).Name))
{
return;
}
scope = _repackContext.PlatformFixer.FixPlatformVersion(((AssemblyNameReference)type.Scope));
}
else if (type.Scope is ModuleReference)
{
if (_repackContext.MergedAssemblies.SelectMany(x => x.Modules).Any(x => x.Name == ((ModuleReference)type.Scope).Name))
{
return;
}
// TODO fix scope (should probably be added to target ModuleReferences, otherwise metadatatoken will be wrong)
// I've never seen an exported type redirected to a module, doing so would be blind guessing
scope = type.Scope;
}
if (type.IsForwarder)
{
// Skip duplicated forwarders
var fullName = type.FullName;
if (col.Any(t => t.IsForwarder && t.FullName == fullName))
{
return;
}
}
var nt = new ExportedType(type.Namespace, type.Name, module, scope)
{
Attributes = type.Attributes,
Identifier = type.Identifier, // TODO: CHECK THIS when merging multiple assemblies when exported types ?
DeclaringType = type.DeclaringType
};
col.Add(nt);
}