protected override Expression VisitListInit(ListInitExpression expression) { if (expression == null) { throw new ArgumentNullException(nameof(expression)); } Visit(expression.Initializers, VisitElementInit); // Visit the NewExpression only if the List initializers is evaluatable. It makes no sense to evaluate the NewExpression if the initializers // cannot be evaluated. if (!IsCurrentSubtreeEvaluatable) { return(expression); } Visit(expression.NewExpression); // Testing the parent expression is only required if all children are evaluatable if (IsCurrentSubtreeEvaluatable) { IsCurrentSubtreeEvaluatable = EvaluatableExpressionFilter.IsEvaluatableListInit(expression); } return(expression); }
protected override Expression VisitListInit(ListInitExpression expression) { ArgumentUtility.CheckNotNull("expression", expression); Visit(expression.Initializers, VisitElementInit); // Visit the NewExpression only if the List initializers is evaluatable. It makes no sense to evaluate the NewExpression if the initializers // cannot be evaluated. if (!_isCurrentSubtreeEvaluatable) { return(expression); } Visit(expression.NewExpression); // Testing the parent expression is only required if all children are evaluatable if (_isCurrentSubtreeEvaluatable) { _isCurrentSubtreeEvaluatable = _evaluatableExpressionFilter.IsEvaluatableListInit(expression); } return(expression); }