Skip to content

Parameter type mismatch is causing missing methods #87

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

Closed
leniency opened this issue Feb 26, 2021 · 3 comments
Closed

Parameter type mismatch is causing missing methods #87

leniency opened this issue Feb 26, 2021 · 3 comments
Assignees
Labels

Comments

@leniency
Copy link

In 1.4.20 I started having an issue with member methods not being found, specifically on DateTime and DateTimeOffset. Some digging and it looks like the parameter filter are causing some of the basic methods like AddDays(double d) to be excluded when the given parameter is in fact an int.

var evaluator = new ExpressionEvaluator();
evaluator.Evaluate("DateTime.Now.AddDays(1)");

This will yield an exception, CodingSeb.ExpressionEvaluator.ExpressionEvaluatorSyntaxErrorException: [System.DateTime] object has no Method named "AddDays".]

Specifying the variable as a double fixes the issue, evaluator.Evaluate("DateTime.Now.AddDays(1d)"); but this isn't always ideal or obvious as int is implicitly convertable to double and passing an int to AddDays is valid C#.

I see in the commits that this section of code is being worked on - is this something I should try to fix and send in a pull request? Or hold off till next release, or let the maintainers handle?

@codingseb
Copy link
Owner

Hello @leniency.
Thanks for reporting this bug.
Yes the last version introduced some new features (see #83) that required to rewrite some part of the code that search for the good method to call.
I did some tests but I missed these kind of cases. I am sorry about that. I think I know what is wrong. I will correct it as soon as possible and add some tests to cover these cases.
It is possible that others bugs that I missed appears due to last version code rewriting. If so thanks to report it.

@codingseb
Copy link
Owner

I published version 1.4.21.0 that correct this bug.
I created some tests to check theses cases.
So it ensure that this specific bug should not come again.

@leniency
Copy link
Author

leniency commented Mar 2, 2021

Thanks! Updated to 1.4.21 and my tests pass again too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants