This commit reimplements the C# API in terms of a Wasmtime linker. It removes the custom binding implementation that was based on reflection in favor of the linker's implementation. This should make the C# API a little closer to the Rust API. The `Engine` and `Store` types have been hidden behind the `Host` type which is responsible for hosting WebAssembly module instances. Documentation and tests have been updated.
40 lines
865 B
C#
40 lines
865 B
C#
using System;
|
|
using System.IO;
|
|
using Wasmtime;
|
|
|
|
namespace Wasmtime.Tests
|
|
{
|
|
public abstract class ModuleFixture : IDisposable
|
|
{
|
|
public ModuleFixture()
|
|
{
|
|
Host = new HostBuilder()
|
|
.WithMultiValue(true)
|
|
.WithReferenceTypes(true)
|
|
.Build();
|
|
|
|
Module = Host.LoadModuleText(Path.Combine("Modules", ModuleFileName));
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (!(Module is null))
|
|
{
|
|
Module.Dispose();
|
|
Module = null;
|
|
}
|
|
|
|
if (!(Host is null))
|
|
{
|
|
Host.Dispose();
|
|
Host = null;
|
|
}
|
|
}
|
|
|
|
public Host Host { get; set; }
|
|
public Module Module { get; set; }
|
|
|
|
protected abstract string ModuleFileName { get; }
|
|
}
|
|
}
|