Error when using LINQ Select an object or GroupBy an Object
xxyuze opened this issue · comments
Version used
3.0.0-beta-2057
Describe the bug
I can use linq to select a value, but I can't select an object.
var engine = new Engine(cfg => cfg
.AllowClr()
.AddExtensionMethods(typeof(System.Linq.Enumerable))
);
let someArray = [ 2, 4 ];
let newArray = someArray.Select(m => ({a:m,b:m})).ToArray();
The error message "Object must implement IConvertible"
To Reproduce
Ideally code samples or better yet, xUnit test against current main
.
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
Add any other context about the problem here.
Why do you want to dramatically slow down the script performance by using LINQ interop where simple Array.map
would suffice?
The above is just an example to show that although Jint already supports LINQ operations, it seems incomplete. #304
Sometimes you need to operate on .NET objects, and you must use LINQ operations.
In addition, GroupBy will also report the same error.
var engine = new Engine(cfg => cfg
.AllowClr()
.AddExtensionMethods(typeof(System.Linq.Enumerable))
);
;
someDotnetList.GroupBy(m => ({a:m,b:m})).ToArray();
Would you like to help out with a fix PR including missing test coverage for the cases you've found?