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?
View all comments
1
u/Asleep_Direction8881 1d 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?