Replies: 1 comment
-
Greetings, @luanmm, First, thank you very much for your kind words! The ability to interact with individual users is one of the best things about maintaining a small project. ClearScript's evolution is guided largely by those interactions.
ClearScript aims to give script code full access to .NET objects – including their methods – and the same for script objects passed to the host. To that end, it doesn't serialize objects, as serialization produces only a snapshot of an object's public state. Instead, it performs by-reference marshaling; that is, it allows objects on one side to be controlled from the other by proxies. For example, when you pass a .NET object to JavaScript code, the latter gets a proxy bound to the original "live" .NET object. There's no copying of data via serialization or otherwise. Fundamental values such as numbers and strings are an exception, as ClearScript converts them automatically into their respective JavaScript equivalents. Automatic conversion of some other common data types – such as timestamps and tasks/promises – is available on an opt-in basis.
The problem is that most languages don't enforce naming conventions, leaving applications free to create difficulties for automatic name transformation. For something like case, it might be possible to examine the object and transform only non-conflicting names, but that would add complexity to an already expensive marshaling process. Additionally, there are other, more daunting obstacles to "perfect" automatic marshaling. For example, indexing in .NET and JavaScript are markedly different operations. Depending on specific object semantics, one could map easily onto the other or not at all.
If you can share any details about your application or the issues you're encountering with ClearScript, please do so. We'll be happy to take a look and try to help! Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hello,
First of all, thank you for the amazing work in this repository, not only because of the code, but even for the attention regarding people's issues and the complete clarification about every subject.
I'm trying ClearScript in a project to allow it to have some "extension points". Everything seems to be feasible for now, but for some scenarios like mine, the simplicity is something important and I see two main improvement points regarding this subject:
System.Text.Json
as serializer to make it possible to pass arrays/objects "as is" between C# / JavaScript;The second point could even be easier for scenarios like stated in the first point because the "STJ" serializer has defaults for web that do exactly that: keeps the PascalCase/camelCase as it should be in a good C# / JavaScript conversation. But I thought it would be good to point this because there are lots of samples in the repository (or in the docs) where naming conventions does not seems to have that importance.
I am already using some strategies to keep the casing "automatic" (as
CamelCaseAttributeLoader
, for instance), but I really think that it should be the "default" as it is inSystem.Text.Json
library (of course, it could be flagged/configured like theJsonSerializer
is).Regarding object mapping, I'm trying some strategies here to architect something simple that helps me with the current ClearScript version, but without much success for now (as I'm new to the library and do not know its internals). Hope to advance to find a way to serialize/deserialize when the library does not find a way to do so.
Anyway... thanks for all the efforts regarding this library/repository and hope the project could advance as I see it has in the past few years!
Best regards!
Beta Was this translation helpful? Give feedback.
All reactions