zzzprojects / Eval-Expression.NET

C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime.
https://eval-expression.net/
Other
459 stars 86 forks source link

Wrong generic when using the Expression lambda and Statement lambda in Linq #88

Closed cesaryuan closed 3 years ago

cesaryuan commented 3 years ago
var context = new EvalContext();
var test1 = context.Execute(@"
    var test = new List<string>{""test""}.Select(x => {return x;}).ToList();
    return test.GetType().ToString();"); // System.Collections.Generic.List`1[System.Object]
var test2 = context.Execute(@"
    var test = new List<string>{""test""}.Select(x => x).ToList();
    return test.GetType().ToString();"); // System.Collections.Generic.List`1[System.String]

When I execute the above sentences, its result is not as expected which should both be the "System.Collections.Generic.List`1[System.String]".

The main differences between test1 and test2 is the lambdas used in "Select" that one is Expression lambda but the other is Statement lambda.

Version: 4.0.26

JonathanMagnan commented 3 years ago

Hello @cesaryuan ,

Thank you for reporting.

I also agree that both should return a List<string>.

We will look at it.

Best Regards,

Jon

JonathanMagnan commented 3 years ago

Hello @cesaryuan,

The v4.0.27 has been released.

Could you try the latest version and let me know if my developer correctly fixed your issue?

Best Regards,

Jon

cesaryuan commented 3 years ago

@JonathanMagnan Thanks, it works for me. 👍