Pass a big c# object to JS
I'm passing to JS a big c# object using RegisterProxyConverter. I've tried also to to use RegisterStructConverter, but the problem is always the same: the process is slow because, practically I have to describe the methods and properties to JS and it take time for large objects. Looking to the source code I notice that RegisterProxyConverter uses the API 'JSCreateExternalObject' with the first argument set to null. ( the object pointer ). Is any way to pass the c# object pointer using the API 'JSCreateExternalObject' and use it ? I've seen this example https://github.com/robertlong/ChakraLogExample/tree/master/ChakraLogExample where a class is passed to JS.
Sorry for the late response, was a bit busy these days. the sample your provied is using a prototype "JSLogPrototype" (line 65) to describe the methods and properties for the object instance ( line 93-110 ) , which still need to be hardcoded. Currently there's no good solution for your problem, I think a code generator might be helpful. But I'm afraid I don't have enough bandwidth to do this these days :(
Thank you for your answer. What do you mean for a 'code generator'? Currently I'm passing to js a json that generate the object in JS. Are we talking about the same approach ? The problem is that for a big object this approach is slow, so I was wonder if there a faster way.
seems we're not talking the same thing, code generator means "reflect C# big class and generate the proxy registry code". from your latest post, my understanding is you're trying to pass a complex structure from C# to JS. to avoid hard code all the properties in C#, you're passing a json string to the js then restore it as an object in js.
you're doing the exactly what I'm doing in my other project. I'm thinking add a helper method may help, it serialize your POCO object ( to json) and restore it in JS. If you like this, please create a new issue to help me track this request.
thank you for the confirmation. No I don't need an helper. I've already developed all the code. Since it is a very custom serializer/deserializer it does not make any sense that I share it
no worry, please feel free to keep it to your own project. I'm considering create a new JS wrapper which target V8 engine as chakracore will no longer be actively developed.
This is a very bad news. I'm coming from Edge.js and practically I have to redo everything again to return back to V8. How can I know if/when you start to write the new wrapper ?
I will try my best to remain the high level api(context , hosting) remain same. Ideally I will start the new project at march.