WACS.HostBindings.Abstractions
0.3.0
dotnet add package WACS.HostBindings.Abstractions --version 0.3.0
NuGet\Install-Package WACS.HostBindings.Abstractions -Version 0.3.0
<PackageReference Include="WACS.HostBindings.Abstractions" Version="0.3.0" />
<PackageVersion Include="WACS.HostBindings.Abstractions" Version="0.3.0" />
<PackageReference Include="WACS.HostBindings.Abstractions" />
paket add WACS.HostBindings.Abstractions --version 0.3.0
#r "nuget: WACS.HostBindings.Abstractions, 0.3.0"
#:package WACS.HostBindings.Abstractions@0.3.0
#addin nuget:?package=WACS.HostBindings.Abstractions&version=0.3.0
#tool nuget:?package=WACS.HostBindings.Abstractions&version=0.3.0
WACS.HostBindings.Abstractions
The shared vocabulary for WACS host bindings. Exposes:
[WacsImport(string module, string name)]— annotate a static method as the implementation of a wasm import. Consumed byWACS.HostBindings.SourceGenat consumer build time.[WacsImportNames(string mapping)]— assembly-level mapping for save-to-dll outputs whose method-level attributes don't survive the PE serializer.[WacsTranspiledImports]— marks a generated imports type for the transpiler's source-gen pickup.[WasmName(string)]— round-trips the original wasm name (e.g.wasi:cli/run@0.2.0#run) on auto-generatedIExports/IImportsmethods whose CLR identifier got sanitized (wasi_cli_run_0_2_0_run). Stamped automatically by the WACS interface generator; consumers reflect on it for dispatch and diagnostics.[assembly: WasiHostPackage(string? label)]— assembly-level marker flagging an assembly as a WACS host package — discoverable byruntime.AutoDiscoverHostPackages(). Pairs with the explicit-listruntime.UseHostPackages(name1, name2, …).WacsHostMemory— a 16-byte readonly struct view over wasm linear memory, passed as the first parameter to every binding method. Bounds-checked accessors plus anAsSpanescape hatch for bulk I/O.WacsHostFault— exception type for binding-side traps. Surfaced as a wasm runtime fault by the caller.
Tiny by design. No runtime allocations, AOT-clean, netstandard2.0 so the matching Roslyn source generator can reference it directly.
Authoring a host binding
public static class MyEngineBindings
{
[WacsImport("game_engine", "log")]
public static void Log(WacsHostMemory mem, int strPtr, int strLen)
{
var span = mem.AsSpan(strPtr, strLen);
Console.WriteLine(System.Text.Encoding.UTF8.GetString(span));
}
[WacsImport("game_engine", "rand")]
public static int Rand(WacsHostMemory mem, int max)
=> Random.Shared.Next(max);
}
The first parameter is always WacsHostMemory (host code may need it).
Subsequent parameters match the wasm import's typed signature.
Per-call shared state
Bindings that need long-lived state (file descriptors, configuration, etc.) take a state parameter as the second argument:
public static class WasiPreview1Bindings
{
[WacsImport("wasi_snapshot_preview1", "fd_write")]
public static int FdWrite(WacsHostMemory mem, State state,
int fd, int iovs, int iovs_len, int nwritten)
{
// … implementation backed by `state.FileDescriptors[fd]`
}
}
The source generator detects state-typed parameters via type identity and
threads them through from a constructor on GeneratedHostImports.
Multiple bindings sharing the same state type share the same constructor
parameter.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Memory (>= 4.5.5)
-
net8.0
- No dependencies.
NuGet packages (6)
Showing the top 5 NuGet packages that depend on WACS.HostBindings.Abstractions:
| Package | Downloads |
|---|---|
|
WACS.WASI.NN
WASI-NN host bindings for WACS — wasi:nn@0.2.0-rc-2024-10-28 (component-model WIT) plus the legacy wasi_ephemeral_nn (WITX) ABI. Backend-agnostic core; pluggable backends (ML.NET, ONNX Runtime, ONNX Runtime GenAI, LlamaSharp, TorchSharp, OpenVINO) ship as sibling packages. Tracks the wasi-nn proposal at WASI Phase 2 — the WIT surface may change as the proposal evolves. |
|
|
WACS.Transpiler.Lib
Library API for WACS.Transpiler — programmatic ahead-of-time WebAssembly-to-.NET IL transpilation, plus seamless loading of saved transpiled assemblies. v0.7.2 fixes a re-instantiation bug where Module classes with active data segments would come up zeroed on the second `Activator.CreateInstance` because spec §4.5.4 segment-drop emptied the process-wide ModuleInit registry. Module ctors now restore from `ModuleInitData.SavedDataSegments` before each CopyDataSegment so every fresh instance sees its memory initialized. v0.7 retires Lokad.ILPack for PersistedAssemblyBuilder (.NET 9), moves WASM data segments + the codec blob to RVA-mapped initialized data (62.5% smaller than the prior base64-in-#US path, true zero-copy from PE pages to ModuleInitData via UnmanagedMemoryStream), and introduces EmissionTarget.Auto as the new default — promotes to AotLinked when the module fits a conservative envelope (compute / memory / globals / tables + active+passive segments / multi-memory / local tags / imported functions), falling back to Standard otherwise. ~50% first-trial cold-start cut on promoted modules. ImportDispatcher now throws on missing handlers by default (lenient: true opts out). v0.6 consumed the Branch Hinting proposal's metadata.code.branch_hint custom section. v0.5 added the AotLinked emission target, stable AssemblyName, and the [WacsTranspiledImports] / [WacsImportNames] emission used by WACS.HostBindings.SourceGen. |
|
|
WACS.WASI.Preview1
WASI Preview 1 implementation for WACS. Successor to the deprecated WACS.WASIp1 package; identical API under the new Wacs.WASI.Preview1 namespace. C# `TypeForwardedTo` cannot bridge a namespace rename, so the deprecated WACS.WASIp1 package is now a metapackage that pulls this assembly in transitively while consumers update their `using Wacs.WASIp1;` lines to `using Wacs.WASI.Preview1;` (one-shot sed in docs/MIGRATION_WASIp1_to_WASI.md). v0.12.0 lifts 23 wasi-testsuite fixtures (Phase 4): symlink behavior modes (no-follow lstat, dangling-target unlink, ELOOP on path_open), trailing-slash semantics, fd_readdir . / .., directory FD own-vs-inherited rights split, real Unix st_ino via stat(2), Clock.ToDateTimeUtc nanosecond fix, plus errno tightening (BADF for invalid fds, ENOTDIR / ISDIR / PERM in path_open). 67/72 fixtures pass; remaining 5 are OS-API-specific (lutimes, rename(2)) or runtime-quirk. |
|
|
WACS.WASI.Threads
wasi-threads host-import adapter for WACS. Binds `wasi:thread-spawn` onto the core IWasmThreadHost primitive so wasm modules with shared memory can spawn worker threads. |
|
|
WACS.WASI.GFX
WASI-GFX host bindings for WACS — wasi:graphics-context, wasi:frame-buffer, wasi:surface (all @0.0.1). Backend-agnostic core; the Silk.NET/SDL backend ships as a sibling package. Preview: tracks the wasi-gfx proposal at WASI Phase 2 — the WIT surface may change as the proposal evolves. |
GitHub repositories
This package is not used by any popular GitHub repositories.