agracio / edge-js

Run .NET and Node.js code in-process on Windows, macOS, and Linux
MIT License
643 stars 95 forks source link

No support for multidimensional arrays? #126

Closed teledemic closed 7 months ago

teledemic commented 3 years ago

It looks like a multidimensional array from .NET gets flattened into a single dimension when returning to JS:

/*
async (input) => {
    return new int[,] { { 1, 1, 1 }, { 2, 2, 2 }, {3, 3, 3 } };
}
*/

Value returned to javascript: [ 1, 1, 1, 2, 2, 2, 3, 3, 3 ]

Expected value:

[ [ 1, 1, 1 ],
[ 2, 2, 2 ],
[ 3, 3, 3 ] ]

Thanks for the library, everything else is working great!

agracio commented 3 years ago

Looks like a CLR->V8 marshalling issue, but I am afraid I do not know how to fix it.

teledemic commented 3 years ago

OK thx! I was having a similar thing happen with returned dictionary objects too. For anyone looking, my workaround ended up as just serializing the entire return object to a JSON string (with the newtonsoft json library) and passing that string back as the function return, then deserializing in node with JSON.parse. Clunky but works.