in ILRepack/ReferenceFixator.cs [434:473]
internal MethodReference Fix(MethodReference method)
{
TypeReference declaringType = Fix(method.DeclaringType);
if (method.IsGenericInstance)
{
return Fix((GenericInstanceMethod)method);
}
// if declaring type is in our new merged module, return the definition
if (declaringType.IsDefinition && !method.IsDefinition)
{
MethodDefinition def = new ReflectionHelper(_repackContext).FindMethodDefinitionInType((TypeDefinition)declaringType, method);
if (def != null)
return def;
}
method.DeclaringType = declaringType;
method.ReturnType = Fix(method.ReturnType);
FixReferences(method.Parameters);
FixReferences(method.GenericParameters);
if (!method.IsDefinition &&
!method.DeclaringType.IsGenericInstance &&
!method.DeclaringType.IsArray &&
(method.ReturnType.IsDefinition || method.Parameters.Any(x => x.ParameterType.IsDefinition)))
{
var culprit = method.ReturnType.IsDefinition
? method.ReturnType
: method.Parameters.First(x => x.ParameterType.IsDefinition).ParameterType;
// warn about invalid merge assembly set, as this method is not gonna work fine (peverify would warn as well)
_logger.Warn("Method reference is used with definition return type / parameter. Indicates a likely invalid set of assemblies, consider one of the following");
_logger.Warn(" - Remove the assembly defining " + culprit + " from the merge");
_logger.Warn(" - Add assembly defining " + method + " to the merge");
// one case where it'll work correctly however (but doesn't seem common):
// A references B
// C references A
// C is merged into B
}
return method;
}