private MethodReference GetConstructorResolved(MethodReference commandConstructor, MethodDefinition method) { var parameterType = method.HasParameters ? method.Parameters[0].ParameterType : Assets.TypeReferences.Object; var commandType = commandConstructor.DeclaringType; bool isGeneric = commandType.HasGenericParameters; if (commandType.HasGenericParameters) { var commandTypeResolved = commandConstructor.DeclaringType.MakeGenericInstanceType(parameterType); commandType = commandTypeResolved; var resolvedConstructor = commandType.GetElementType() .Resolve() .GetConstructors() .First(c => c.Parameters.Count == commandConstructor.Parameters.Count); commandConstructor = resolvedConstructor; } if (isGeneric) { if (method.HasParameters) { commandConstructor = commandConstructor.MakeHostInstanceGeneric(method.Parameters[0].ParameterType); } else { commandConstructor = commandConstructor.MakeHostInstanceGeneric(Assets.TypeReferences.Object); } } return commandConstructor; }