zzzprojects / Eval-Expression.NET

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

No applicable member has been found for the expression in Enumerable #20

Closed rogerfar closed 6 years ago

rogerfar commented 6 years ago

When I execute this code:

    static void Main(string[] args)
    {
        var eval = new EvalContext();
        eval.RegisterDomainAssemblies();

        const string test = @"var list = new List<Int32>();
list.Add(2);
list.Add(1);
list = Enumerable.OrderBy(list, m => m).ToList();
return list;
";
        var testList = Test();
        var invoiceAdd = eval.Execute<List<String>>(test);
    }

    private static IList<Int32> Test()
    {
        var list = new List<Int32>();
        list.Add(2);
        list.Add(1);
        list = Enumerable.OrderBy(list, m => m).ToList();
        return list;
    }

I get the following errors: 'Oops! No applicable member has been found for the expression.'

JonathanMagnan commented 6 years ago

Hello @yesman85 ,

Thank you for reporting,

We already found the cause of the issue, we will fix it and provide you a solution for next Monday.

Meanwhile, calling the method like this will work:

const string test = @"var list = new List<Int32>();
list.Add(2);
list.Add(1);
list = list.OrderBy(m => m).ToList();
return list;
";
rogerfar commented 6 years ago

I tried that, unfortunately OrderBy is not whitelisted and it being pulled from the wrong library in my case.

JonathanMagnan commented 6 years ago

Hello @yesman85 ,

The v2.4.6 has been released.

I believe all issue related to this one or you provided by email has been solved in this version.

You do not longer need to try to blacklist some type.

Let me know if everything works fine.

Best Regards,

Jonathan

rogerfar commented 6 years ago

Yes this seems to work!