dotnet / dotnet-wasi-sdk

An SDK for building .NET projects as standalone WASI-compliant modules
MIT License
279 stars 12 forks source link

Exporting functions #33

Open slyons opened 4 months ago

slyons commented 4 months ago

I'm trying to write a module that exports a function so that it's callable from another runtime. I've tried using UnmanagedCallersOnly, which I've seen be usable in other runtimes.

using System.Runtime.InteropServices;
using Extism;

[UnmanagedCallersOnly(EntryPoint = "add_two")]
static int add_two() {

    return 0;
}

I seem to only get the following exported functions:

file format wasm 0x1

Section Details:

Export[6]:
 - memory[0] -> "memory"
 - global[1] -> "__heap_base"
 - global[2] -> "__data_end"
 - func[7882] <_start> -> "_start"
 - func[7883] <free> -> "free"
 - func[7884] <malloc> -> "malloc"

Is this possible to accomplish with this SDK?