WACS 0.15.22

dotnet add package WACS --version 0.15.22
                    
NuGet\Install-Package WACS -Version 0.15.22
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WACS" Version="0.15.22" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WACS" Version="0.15.22" />
                    
Directory.Packages.props
<PackageReference Include="WACS" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WACS --version 0.15.22
                    
#r "nuget: WACS, 0.15.22"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WACS@0.15.22
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WACS&version=0.15.22
                    
Install as a Cake Addin
#tool nuget:?package=WACS&version=0.15.22
                    
Install as a Cake Tool

WACS (C# WebAssembly Interpreter)

Overview

WACS is a pure C# WebAssembly Interpreter designed for .NET environments, including Unity's IL2CPP. It allows seamless execution of WASM modules with minimal setup, offering compatibility and advanced interop features.

Features

  • Pure C# Implementation: Built with C# 9.0/.NET Standard 2.1 (no unsafe code).
  • Unity Compatibility: Supports Unity 2021.3+ with IL2CPP/AOT compatibility.
  • Godot Compatibility: Compatible with Godot Engine - .NET.
  • Full WebAssembly MVP Compliance: Passes the WebAssembly spec test suite.
  • Interop Bindings: Host bindings created through reflection, requiring no boilerplate.
  • WASI Support: WACS.WASI.Preview1 provides a wasi_snapshot_preview1 implementation.

Installation

Install WACS from NuGet:

dotnet add package WACS

Usage Example

Here's a basic example demonstrating how to load and run a WebAssembly module:

using System;
using System.IO;
using Wacs.Core;
using Wacs.Core.Runtime;

var runtime = new WasmRuntime();
runtime.BindHostFunction<Action<char>>(("env", "sayc"), c => Console.Write(c));

using var fileStream = new FileStream("HelloWorld.wasm", FileMode.Open);
var module = BinaryModuleParser.ParseWasm(fileStream);

var modInst = runtime.InstantiateModule(module);
runtime.RegisterModule("hello", modInst);

if (runtime.TryGetExportedFunction(("hello", "main"), out var mainAddr))
{
    var mainInvoker = runtime.CreateInvokerFunc<Value>(mainAddr);
    int result = mainInvoker();
    Console.Error.WriteLine($"hello.main() => {result}");
}

Switch Runtime (opt-in)

An alternative interpreter backed by a source-generated monolithic switch over an annotated bytecode stream — typically 1.5–2× the polymorphic runtime on compute-heavy workloads, AOT-safe, same correctness (118/118 wast files pass).

Set both flags before InstantiateModule — the switch runtime eagerly compiles every module-owned function at link time when enabled:

var runtime = new WasmRuntime();
runtime.UseSwitchRuntime = true;
runtime.ExecContext.Attributes.UseSwitchSuperInstructions = true;  // optional stream-fuser

var modInst = runtime.InstantiateModule(module);

See Compilation/SWITCH_RUNTIME.md for the full architecture. The polymorphic runtime stays the default path.

License

WACS is distributed under the Apache 2.0 License, allowing usage in both open-source and commercial projects.

Product 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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on WACS:

Package Downloads
Hako.Backend.WACS

A Hako backend which uses https://github.com/kelnishi/WACS, a WebAssembly runtime implemented in .NET Using this backend allows a .NET application using Hako to compile to any target where .NET is supported

WACS.ComponentModel

WebAssembly Component Model support for WACS. Provides the WIT IDL parser, component types, canonical ABI lift/lower, component instantiation, and the host binding surface for running .component.wasm modules on the WACS runtime and AOT transpiler.

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.Preview2.DependencyInjection

Microsoft.Extensions.DependencyInjection extension methods for WACS.WASI.Preview2. Registers default host implementations + bindings + a pre-wired Linker.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on WACS:

Repository Stars
6over3/hako
An embeddable, lightweight, secure, high-performance JavaScript engine.
Version Downloads Last Updated
0.15.22 173 5/18/2026
0.15.20 289 5/16/2026
0.15.19 414 5/12/2026
0.13.8 413 5/11/2026
0.13.7 1,106 5/10/2026
0.12.1 103 5/7/2026
0.10.0 388 5/1/2026
0.9.1 102 4/23/2026
0.9.0 147 4/23/2026
0.8.3 119 4/21/2026
0.8.2 99 4/21/2026
0.8.1 94 4/20/2026
0.8.0 102 4/18/2026
0.7.5 532 11/3/2025
0.7.4 252 2/24/2025
0.7.3 210 2/6/2025
0.7.2 205 2/6/2025
0.7.1 366 2/6/2025
0.7.0 193 1/14/2025
0.6.0 247 12/15/2024
Loading failed