Skip to content

Commit

Permalink
Merge pull request #389 from schleupen/fix_renamed_type_already_exists
Browse files Browse the repository at this point in the history
If the renamed type already exists, use a random name.
  • Loading branch information
KirillOsenkov authored Feb 1, 2025
2 parents 9a32097 + a035701 commit e8e56da
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ILRepack/RepackImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ public TypeDefinition Import(TypeDefinition type, Collection<TypeDefinition> col
// rename the type previously imported.
// renaming the new one before import made Cecil throw an exception.
string other = GenerateName(nt, originalModule?.Mvid.ToString());

//Check whether renamed type already exists
TypeDefinition otherNt = _repackContext.TargetAssemblyMainModule.GetType(other);
if (otherNt != null)
{
//Create a random name
other = GenerateName(nt);
}

_logger.Verbose("Renaming " + nt.FullName + " into " + other);
nt.Name = other;
nt = CreateType(type, col, internalize, null);
Expand Down

0 comments on commit e8e56da

Please sign in to comment.