SteveSandersonMS / dotnet-wasi-sdk

Packages for building .NET projects as standalone WASI-compliant modules
518 stars 36 forks source link

[Question]: Thoughts around possibilities #21

Closed shaggygi closed 2 years ago

shaggygi commented 2 years ago

I've been trying to read up in this space as it appears to have great potential. When it comes to C# and .NET, I'm a little confused on the type of scenarios we may get. Understanding this SDK (and standards around WASI and such) are in the early stages and things will change, but could you add somewhere in the project some docs about things to expect (both good and bad).

For example, will it be possible to write and convert small C# code (few classes) into WASM byte code or is the .NET runtime going to be required as well? What are some of the file sizes seen when building average type of app? Would it be possible to run C# code in smaller micros on bare metal like ESP32?

Thanks for any details provided while progress is made. Enjoyed your WASI sessions so far. Keep up the good work. 👍

shaggygi commented 2 years ago

Will there eventually be ease of adding bindings/support like mentioned here...

https://github.com/bytecodealliance/wasm-micro-runtime/issues/1258

SteveSandersonMS commented 2 years ago

In the long run, alternative .NET compilation technologies such as NativeAOT might get you towards your goal of running tiny snippets of .NET on embedded devices.

The code in this repo is based on the Mono runtime (which is well tested for use on WebAssembly), which does bring in a .NET runtime. I'm not sure which kinds of microcontrollers can run wasm modules in the few-megabytes size range, but those ones should be able to run it.

Will there eventually be ease of adding bindings/support like mentioned here...

In that thread they are talking about embedding WAMR inside Go/C. The equivalent would be embedding WAMR inside .NET. And something very much like that is already possible: the wasmtime NuGet package embeds wasmtime in .NET.

shaggygi commented 2 years ago

In that thread they are talking about embedding WAMR inside Go/C. The equivalent would be embedding WAMR inside .NET. And something very much like that is already possible: the wasmtime NuGet package embeds wasmtime in .NET.

I was asking more about device bindings we have over in dotnet/iot where we can access hardware like I2C/SPI/GPIO. Rich Lander mentioned on another thread (couldn't find it) that it seems it would be possible where new classes could be added specific for WASM (GpioWasmController, etc.).

Thanks again.

SteveSandersonMS commented 2 years ago

In that case, I think https://github.com/SteveSandersonMS/dotnet-wasi-sdk/issues/30 is what you'd want to get from .NET code to arbirary wasm imports/exports, and then it's up to your wasm host to map those imports/exports to whatever native functionality it wants (e.g., GPIO).