Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ILRepack/ReferenceFixator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ private FieldReference Fix(FieldReference field)
field.DeclaringType = Fix(field.DeclaringType);
if (field.DeclaringType.IsDefinition && !field.IsDefinition)
{
FieldDefinition def = ((TypeDefinition)field.DeclaringType).Fields.FirstOrDefault(x => x.Name == field.Name);
var matches = ((TypeDefinition)field.DeclaringType).Fields.Where(f => f.Name == field.Name).ToList();
FieldDefinition def = matches.Count > 1 ?
matches.FirstOrDefault(f => f.FieldType.FullName == field.FieldType.FullName) :
matches.FirstOrDefault();
if (def == null)
throw new NullReferenceException("Field \"" + field + "\" not found in type \"" + field.DeclaringType + "\".");
throw new NullReferenceException("Field \"" + field + "\" with field type \"" + field.FieldType + "\" not found in type \"" + field.DeclaringType + "\".");
return def;
}
field.FieldType = Fix(field.FieldType);
Expand Down
2 changes: 1 addition & 1 deletion ILRepack/RepackImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private bool ShouldDrop<TMember>(TMember member) where TMember : ICustomAttribut
/// </summary>
private void CloneTo(FieldDefinition field, TypeDefinition nt)
{
if (nt.Fields.Any(x => x.Name == field.Name))
if (nt.Fields.Any(x => x.Name == field.Name && x.FieldType.FullName == field.FieldType.FullName))
{
return;
}
Expand Down