Files
wasmtime/crates/misc/dotnet
Alex Crichton bd374fd6fc Add Wasmtime-specific C API functions to return errors (#1467)
* Add Wasmtime-specific C API functions to return errors

This commit adds new `wasmtime_*` symbols to the C API, many of which
mirror the existing counterparts in the `wasm.h` header. These APIs are
enhanced in a number of respects:

* Detailed error information is now available through a
  `wasmtime_error_t`. Currently this only exposes one function which is
  to extract a string version of the error.

* There is a distinction now between traps and errors during
  instantiation and function calling. Traps only happen if wasm traps,
  and errors can happen for things like runtime type errors when
  interacting with the API.

* APIs have improved safety with respect to embedders where the lengths
  of arrays are now taken as explicit parameters rather than assumed
  from other parameters.

* Handle trap updates

* Update C examples

* Fix memory.c compile on MSVC

* Update test assertions

* Refactor C slightly

* Bare-bones .NET update

* Remove bogus nul handling
2020-04-06 15:13:06 -05:00
..
2020-03-25 18:47:59 -07:00
2020-03-25 18:47:59 -07:00
2020-03-25 18:47:59 -07:00
2019-12-13 17:25:12 -08:00
2019-12-13 17:25:12 -08:00

Wasmtime for .NET

A .NET API for Wasmtime.

Wasmtime for .NET enables .NET code to instantiate WebAssembly modules and to interact with them in-process.

Getting Started

Prerequisites

.NET Core 3.0

Install a .NET Core 3.0+ SDK for your operating system.

Introduction to Wasmtime for .NET

See the introduction to Wasmtime for .NET for a complete walkthrough of how to use Wasmtime for .NET.

Wasmtime for .NET API documentation

See the Wasmtime for .NET API documentation for documentation on using the Wasmtime for .NET types.

Running the "Hello World" Example

The "hello world" example demonstrates a simple C# function being called from WebAssembly.

To run the "hello world" example, follow these instructions:

  1. cd examples/hello
  2. dotnet run

You should see a Hello from C#, WebAssembly! message printed.

Building Wasmtime for .NET

To build Wasmtime for .NET, follow these instructions:

  1. cd src.
  2. dotnet build.

This should produce a Wasmtime.Dotnet.dll assembly in the bin/Debug/netstandard2.1 directory.

To build a release version of Wasmtime for .NET, follow these instructions:

  1. cd src.
  2. dotnet build -c Release.

This should produce a Wasmtime.Dotnet.dll assembly in the bin/Release/netstandard2.1 directory.

Running the tests

To run the Wasmtime for .NET unit tests, follow these instructions:

  1. cd tests.
  2. dotnet test.

Packing Wasmtime for .NET

To create a NuGet package for Wasmtime for .NET, follow these instructions:

  1. cd src.
  2. dotnet pack -c Release.

This should produce a Wasmtime.<version>.nupkg file in the bin/Release directory.

Implementation Status

Status

Feature Status
Wasmtime engine class
Wasmtime store class
Wasmtime module class
Wasmtime instance class 🔄
Module function imports
Module global imports
Module table imports
Module memory imports
Module function exports
Module global exports
Module table exports
Module memory exports
Extern instance functions
Extern instance globals
Extern instance tables
Extern instance memories
Host function import binding
Host global import binding
Host table import binding
Host memory import binding
i32 parameters and return values
i64 parameters and return values
f32 parameters and return values
f64 parameters and return values
AnyRef parameters and return values
Tuple return types for host functions
Trap messages
Trap frames
Create a NuGet package

Legend

Status Icon
Not implemented
In progress 🔄
Completed