You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So ExpressionPromoter.Promote returns the expression for string enumerable but for int enumerable it returns null, due to which we get an error saying no method Join found.
Whereas normally(in c#) when we use int enumerable obj with string.Join it works perfectly, probably because it's matching with the below two types.
I would like to know if in your lib can you please make your best method search approach to be more wider which can detect generic methods too? String.Join is just an example, this change can be very useful for many methods.
Code to reproduce the issue:
Works
var strArray = new[] { "1","2","3","4"};
var x = new List<ParameterExpression>();
x.Add(Expression.Parameter(strArray.GetType(), "strArray"));
var config = new ParsingConfig();
string query = "string.Join(\",\" , strArray)";
var e = DynamicExpressionParser.ParseLambda(config, x.ToArray(), null, query);
Delegate del = e.Compile();
var result = del.DynamicInvoke(strArray);
Doesn't Work
var intArray = new[] { 1,2,3,4};
var x = new List<ParameterExpression>();
x.Add(Expression.Parameter(intArray.GetType(), "intArray"));
var config = new ParsingConfig();
string query = "string.Join(\",\" , intArray)";
var e = DynamicExpressionParser.ParseLambda(config, x.ToArray(), null, query);
Delegate del = e.Compile();
var result = del.DynamicInvoke(intArray);
Thanks!
The text was updated successfully, but these errors were encountered:
We looked at this issue and in the short term, I don't think we will improve the method overload resolution. Way too much code is involved to make it works or improve it. A major code revamps would be required which will come without a doubt a major version if we do it.
If we want to make it works correctly, we will have to bring back the method overload resolution we did in our other library (C# Eval Expression) which took us weeks to make it works (and still is not 100% perfect but close enough).
So, if you wish a better method resolution, I recommend you to try https://eval-expression.net/ (free for LINQ part). Otherwise, I don't think anything will be done in short term.
Hi,
I am highlighting one constraint/issue which is little annoying and could be improved upon.
When I use String.Join method below are the possible overloads which can be called.
Now in ExpressionPromoter.Promote class of your lib the type match is exact for IEnumerable types.
For example below are the two types, one for string enumerable and another one is int enumerable obj.
So ExpressionPromoter.Promote returns the expression for string enumerable but for int enumerable it returns null, due to which we get an error saying no method Join found.
Whereas normally(in c#) when we use int enumerable obj with string.Join it works perfectly, probably because it's matching with the below two types.
I would like to know if in your lib can you please make your best method search approach to be more wider which can detect generic methods too? String.Join is just an example, this change can be very useful for many methods.
Code to reproduce the issue:
Works
Doesn't Work
Thanks!
The text was updated successfully, but these errors were encountered: