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

SelectMany() not fond #158

Open cuiliang opened 6 months ago

cuiliang commented 6 months ago

code:

var dictList = new List<Dictionary<string, string>>
{
    new Dictionary<string, string>()
    {
        {"key1", "value1"},
        {"key2", "value2"}
    },
    new Dictionary<string, string>()
    {
        {"key3", "value3"},
        {"key4", "value4"}
    }
};

var mergedDict = dictList
    .SelectMany(d => d)
    .ToDictionary(kv => kv.Key, kv => kv.Value);

error: Oops! No applicable member has been found for the expression. The error occurred for expression "." at position 315 near ".SelectMany(d => d)

Full source code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Z.Expressions;

namespace ConsoleApp7
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string code = """
                          var dictList = new List<Dictionary<string, string>>
                          {
                              new Dictionary<string, string>()
                              {
                                  {"key1", "value1"},
                                  {"key2", "value2"}
                              },
                              new Dictionary<string, string>()
                              {
                                  {"key3", "value3"},
                                  {"key4", "value4"}
                              }
                          };

                          var mergedDict = dictList
                            .SelectMany(d => d)
                            .ToDictionary(kv => kv.Key, kv => kv.Value);
                          """;

            try
            {
                Eval.Execute(code);

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
            Console.ReadLine();
        }
    }
}
JonathanMagnan commented 6 months ago

Hello @cuiliang ,

Thank you for reporting, we will try to reproduce the issue with your information

Best Regards,

Jon

JonathanMagnan commented 6 months ago

Hello @cuiliang ,

Thank you again for reporting.

My developer is currently able to reproduce the issue. Unfortunately, he is currently requesting some help, and I'm on vacation.

So I will look into this issue when I am back on May 20, so it will take longer to fix or progress.

Best Regards,

Jon

cuiliang commented 6 months ago

@JonathanMagnan It's okay, I'm not in a hurry, wish you a happy vacation!