Skip to content

Commit

Permalink
Revert changes done in #296
Browse files Browse the repository at this point in the history
  • Loading branch information
metoule committed Nov 16, 2024
1 parent f26a4e2 commit 1675a6d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DynamicExpresso.Core/Resolution/ExpressionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static Expression PromoteExpression(Expression expr, Type type)
return Expression.Convert(expr, genericType);
}

if (TypeUtils.IsCompatibleWith(expr.Type, type) || expr is DynamicExpression)
if (TypeUtils.IsCompatibleWith(expr.Type, type))
{
return Expression.Convert(expr, type);
}
Expand Down
16 changes: 16 additions & 0 deletions test/DynamicExpresso.UnitTest/GithubIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ public void GitHub_Issue_292()
}

[Test]
[Ignore("The fix suggested in #296 break other use cases, so let's ignore this test for now")]
public void GitHub_Issue_295()
{
var evaluator = new Interpreter();
Expand Down Expand Up @@ -849,6 +850,21 @@ public void GitHub_Issue_314()
var exception2 = Assert.Throws<UnknownIdentifierException>(() => interpreter.Eval("b > 1"));
Assert.AreEqual("b", exception2.Identifier);
}

[Test]
public void GitHub_Issue_325()
{
var options = InterpreterOptions.Default | InterpreterOptions.LateBindObject;
var interpreter = new Interpreter(options);

var input = new
{
Prop1 = 4,
};

var expressionDelegate = interpreter.ParseAsDelegate<Func<object, bool>>($"input.Prop1 == null", "input");
Assert.IsFalse(expressionDelegate(input));
}
}

internal static class GithubIssuesTestExtensionsMethods
Expand Down

0 comments on commit 1675a6d

Please sign in to comment.