-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
Lazy compile in lambda #219
Lazy compile in lambda #219
Conversation
Renamed Parameter.Is to Parameter.Create
@davideicardi @metoule As a workaround to fix #207 could we merge in this lazy delegate compile, so I can use raw expression without default delegate compile overhead? |
That's a good first step, that has minimal impact on the current interface. However, that alone won't fix #207 because the root cause is the UsedParameters vs DeclaredParameters. I think maybe it should be set to false by default but that is potentially a major change. PS. I'm currently on holidays, with minimal access to a computer, so I won't be able to push commits for a few days. |
I won't use Lambda.Invoke. Since the exception highlighted in #207 comes from compile in Lambda constructor you can do the following: // parameters
var parameters = ...;
// parse
var lambda = interpreter.SetExpression(innerExpression).Parse(expressionText, parameters);
// custom compile and pass all required parameters myself
var delegate = Expression.Lambda(lambda.Expression, parameters).Compile();
// invoke
var result = delegate.DynamicInvoke(....) Am I missing something? |
In that case, the lazy compilation is enough :) |
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.
LGTM!
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.
LGTM! Thank you very much @halamah !
I will merge this and release a new version.
But let's keep #211 and related PRs open, because I think that your original idea is the right solution for the future.
Published v2.10.0! Thank you again @halamah |
Lazy compile delegate in Lambda so the internal Expression can be processed in custom way without default compile overhead.