r/csharp • u/MrLyttleG • 1d ago
ScriptLangCore
/r/moderndotnet/comments/1xv1bst/scriptlangcore/1
u/Asleep_Direction8881 9h ago
Two questions about embedding. First, how does a script reach the host application's own classes and objects? For me that is the main point of an embedded scripting engine: the script works with the app's domain objects, calls their methods, reads and changes their properties. With NativeAOT and a C ABI, can a C# host expose its own types and live instances to a script, or does everything cross the boundary as JSON? If types can be exposed, how is that done without runtime reflection: explicit registration, a source generator, something else?
Second, exceptions across that boundary. If a host method called from a script throws, can the script catch it as a typed exception, with the original type and message? And the other way: when a script throws and nothing catches it, what does the host get: a .NET exception, an error code, the JSON verdict, and does it carry the script file and line?
1
u/Asleep_Direction8881 9h ago
One more: what is the intended way to embed it in a .NET application? Is there a NuGet package with a managed API, or does a C# host go through the C ABI with P/Invoke? And does the embeddable DLL run only on Windows x64, or is a Linux build planned? Most .NET services I work on run in Linux containers.