public ConstructorInfo LoadConstructor(MethodReference methodReference)
{
if (methodReference.Name != ".ctor")
throw new Exception($"the method {methodReference.FullName} is not a constructor");
Type[] paramTypes = methodReference.Parameters.Select(p => Load(p.ParameterType)).ToArray();
if (paramTypes.Any(t => t == null))
return null;
return Load(methodReference.DeclaringType)?
.GetConstructor(paramTypes);
}
}