private Expression CreateCtorArgComparison (ExpressionType expressionType, NewExpression leftNewExpression, NewExpression rightNewExpression)
{
if (!leftNewExpression.Constructor.Equals (rightNewExpression.Constructor))
{
var message = string.Format (
"The results of constructor invocations can only be compared if the same constructors are used for both invocations. "
+ "Expressions: '{0}', '{1}'",
FormattingExpressionTreeVisitor.Format (leftNewExpression),
FormattingExpressionTreeVisitor.Format (rightNewExpression));
throw new NotSupportedException (message);
}
return leftNewExpression.Arguments
.Select ((left, i) => (Expression) Expression.MakeBinary (expressionType, left, rightNewExpression.Arguments[i]))
.Aggregate ((previous, current) => CombineComparisons (previous, current, expressionType, leftNewExpression, rightNewExpression));
}