Open bacongobbler opened 3 weeks ago
One way we may be able to fix this is through reflection. We can use System.Reflection.Assembly.GetExecutingAssembly()
to find the first type that implements IIncomingHandler
and call its Handle
method.
Rough pseudo-code:
IIncomingHandler handler = System.Reflection.Assembly.GetExecutingAssembly().GetTypes().First(myType => myType.GetInterfaces().Contains(typeof(IIncomingHandler)));
handler.Handle((resource), (resource0));
This issue probably belongs on the wit-bindgen
repo, since that's what generates the code.
Also, keep in mind reflection support is limited for Native AOT builds.
Currently, all of the sample projects must be declared under the
SpinHttpWorld.wit.exports.wasi.http.v0_2_0
namespace:It'd be nice if we could change the entrypoint's namespace to match our project name. e.g. if I have a project named
MyProject
:If you change the namespace, you'll see an error when building the project:
This is because
wasmExportHandle
expects to call a type referred to asIncomingHandlerImpl
in the same namespace:https://github.com/dicej/spin-dotnet-sdk/blob/e008b0885c9d1c3aea3123428496aa05df48b57e/src/SpinHttpWorld.wit.exports.wasi.http.v0_2_0.IncomingHandlerInterop.cs#L14-L28