-
-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make handling of MatchExpression
more robust
#768
Conversation
@@ -33,7 +33,7 @@ public static Expression PartialEval(Expression expression, Func<Expression, boo | |||
/// <returns>A new tree with sub-trees evaluated and replaced.</returns> | |||
public static Expression PartialEval(Expression expression) | |||
{ | |||
return PartialEval(expression, e => e.NodeType != ExpressionType.Parameter); | |||
return PartialEval(expression, e => e.NodeType != ExpressionType.Parameter && !(e is MatchExpression)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this change, perhaps it would be better to add a check right inside Evaluator
that recognizes irreducible Extension
nodes.
@@ -334,6 +334,9 @@ private static bool PartialMatcherAwareEval_ShouldEvaluate(Expression expression | |||
case ExpressionType.Parameter: | |||
return false; | |||
|
|||
case ExpressionType.Extension: | |||
return !(expression is MatchExpression); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this change, perhaps it would be better to add a check right inside Evaluator
that recognizes irreducible Extension
nodes.
This is extracted from, and required by, #767. Moq should be able to process expressions containing a
MatchExpression
more or less everywhere except during compilation (because it doesn't carry enough information to properly allow that scenario).