Open
Description
The expression evaluator fails to identify and call the correct instance of an overloaded method in a context object when a Func<>
-parameter is included. Instead, the top implemented instance of the overloaded method with correct number of parameters is being called, which causes an ExpressionEvaluatorSyntaxErrorException
since the Func<>
-parameter isn't convertible to its data type.
In the example below the evaluator will try to convert the Func<>
x => true
to a string.
However, this works fine when Hello(Func<string, bool> filter)
is implemented above Hello(string name)
. This hasn't always been a requirement though, for example this error doesn't occur in version 1.4.21. I don't know in which version this error first occured.
[EXAMPLE]
void Main()
{
var evaluator = new CodingSeb.ExpressionEvaluator.ExpressionEvaluator {
Context = new Test()
};
var result = evaluator.Evaluate("Hello(x => true)");
}
public class Test
{
public string Hello(string name) {
return $"Hello {name}!";
}
public string Hello(Func<string, bool> filter) {
return $"Hello. This method will not be reached!";
}
}
Metadata
Metadata
Assignees
Labels
No labels