in ILRepack/RepackImporter.cs [324:372]
private void CloneTo(PropertyDefinition prop, TypeDefinition nt, Collection<PropertyDefinition> col)
{
// ignore duplicate property
var others = nt.Properties.Where(x => x.Name == prop.Name).ToList();
if (others.Any())
{
bool skip = false;
if (!IsIndexer(prop) || !IsIndexer(others.First()))
{
skip = true;
}
else
{
// "Item" property is used to implement Indexer operators
// It may be specified more than one, with extra arguments to get/set methods
// Note than one may also define a standard "Item" property, in which case he won't be able to define Indexers
// Here we try to prevent duplicate indexers, but allow to merge non-duplicated ones (e.g. this[int] & this[string] )
var args = ExtractIndexerParameters(prop);
if (others.Any(x => _repackContext.ReflectionHelper.AreSame(args, ExtractIndexerParameters(x))))
{
skip = true;
}
}
if (skip)
{
_logger.DuplicateIgnored("property", prop);
return;
}
}
PropertyDefinition pd = new PropertyDefinition(prop.Name, prop.Attributes, Import(prop.PropertyType, nt));
col.Add(pd);
if (prop.SetMethod != null)
pd.SetMethod = FindMethodInNewType(nt, prop.SetMethod);
if (prop.GetMethod != null)
pd.GetMethod = FindMethodInNewType(nt, prop.GetMethod);
if (prop.HasOtherMethods)
{
foreach (MethodDefinition meth in prop.OtherMethods)
{
var nm = FindMethodInNewType(nt, meth);
if (nm != null)
pd.OtherMethods.Add(nm);
}
}
CopyCustomAttributes(prop.CustomAttributes, pd.CustomAttributes, nt);
}