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
feat: Add Host Functions support for .NET SDK #239
Conversation
mhmd-azeez
commented
Jan 23, 2023
•
edited
edited
- Write p/invoke wrappers for new types/functions
- ExtismValType
- ExtismFunction
- ExtismCurrentPlugin
- ExtismValUnion
- ExtismVal
- ExtismFunctionType
- extism_current_plugin_memory
- extism_current_plugin_memory_alloc
- extism_current_plugin_memory_length
- extism_current_plugin_memory_free
- extism_function_new
- extism_function_free
- Write higher level code that allows user to register a function
- Expand the sample code and tests to use host functions
Just taking a moment to come back and look at this as we prepare for a new release. Seems like we have our type definitions but no code yet. @mhmd-azeez do you want me to take a crack at some of the code? Also @ubiquitous-dev have you made any progress on host functions in #264 or are you just waiting on this PR? |
Hi @bhelx, sorry it has been hard to find some time to work on this. Yes, please go ahead. I can give you commit access to the repo so that you can push to the branch directly |
No worries at all! hard for me to find the time as well. I will take a look next week. Any changes I make i will PR into your branch. |
Okay, you already have commit access. If you have any questions please let me know |
Hi @bhelx - the PR #264 is a superset of this PR - it has all the code from here, plus a working asynchronous / cancellable plugin execution engine (depends on the plugin-cancel implementation we've been testing with @zshipko), as well as additional test coverage. I have already added some host function tests based on the Java library's host functions tests, and would love some help on that branch for extending the Host Functions support further. I'll give you commit access to my repo as well. |
@bhelx Host Functions now work in the .NET SDK :D But I'll need to clean it up a little bit and do more tests. Also, the extism panics somewhere, but I have no idea what's going on:
|
@bhelx okay, by looking at the go implementation, I was able to fix some of the marshalling code and now both input and output work. But we still get the panic.
|
I haven’t tested this out yet, but just reading the stack trace, looks like the extism_version function is the issue (maybe it’s involved in logging or something?) I’m not a rust expert, but this code seems to indicate that an env var must be set for extism_version to resolve to a string. Can you try setting that env var? I’m also curious if you call extism_version() directly from your .net project, does that also have an issue? |
Thanks @mhmd-azeez! I am not getting that panic when I run the example program on Ubuntu. I am in the process of getting a Windows dev environment set up, hopefully I can try it out on Windows at some point. Does the sample program use the system extism installation or the one in the repo? Like @lukevp mentioned, the backtrace you posted looks kind of strange because it happens on |
Hello @zshipko the sample uses the extism binaries published in the nuget package published here: https://www.nuget.org/packages/Extism.runtime.win-x64 |
Awesome. We will review ASAP. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, works on my machine! Code looks good. Great work! Really excited about this one. I'm gonna aim to release this early next week, might be earlier though.