-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a way to eagerly marshal (snapshot) all properties to js object. #399
Comments
If you can use a I'm not sure why it doesn't work for a class (which is marshalled by reference). But one thing you could try is to define a toJSON() method on the .NET class, which should then get called by the JS serializer. |
Sadly I can't. It doesn't work probably because the class object doesn't actually have properties defined on it, and it just a proxy? The js JSON.stringify will then not able to serialize anything because theres no fields or properties to serialize. Defining a toJson seems ok but I have to add a base class for everyone, and it still a pain in the ass, because of #400. If I pass the serialized string to other process through IPC, I cannot use it using the existing type definition otherwise I need to load dotnet runtime for every subprocess, which seems not ideal. I then have to manually copy these ts definitions. It probably simpler if I can just import type from generated code, instead of ambient importing a whole dotnet runtime. Or it will not, because serialized string will not fit into the dotnet types, we probably should also generate a pure js types ts definition in seperated files, and to be imported without importing dotnet runtime, that seems a better way to resolve #400. |
I'll investigate why that doesn't work. There might be a way to fix the proxy to allow it to work with JSON.stringify(). Or have the marshaller automatically add a |
When a function returns a class object, it can't be serialized to json and send it across RPC, because all of properties are dynamically loaded. Is there any way to marshal it to a completely JS object? Because compiling into a module doesn't work well.
It will be nice if can provide a snapshot helper to take the snapshot of a reference and let it pass with rpc.
The text was updated successfully, but these errors were encountered: