Skip to content
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

Syntax error calling overloaded method in context object including Func<> parameter #154

Open
antong93 opened this issue Sep 28, 2022 · 0 comments

Comments

@antong93
Copy link

antong93 commented Sep 28, 2022

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!";
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant