zion-sati/NetWasm

Public

Compile C# and .NET CIL to small standalone Wasm with WASI (AOT with built-in Runtime and Precise GC)

  • Stars270+15 tuần này
  • Forks12
  • Watchers2
  • Issues6
  • Ngày tạo10/08/2026
  • Cập nhật gần nhất28/10/2026
  • Ngôn ngữC#
  • Giấy phép—
README.md26.3 KBRaw

NetWasm

Independent .NET for WebAssembly and WASI.
Write C#. Deploy small, standalone Wasm.

NetWasm is an independent compiler, CoreLib, runtime and SDK that compiles C# and .NET CIL directly to WebAssembly. It does not carry the desktop CLR, Mono, dotnet.js or application DLLs into production.

Star NetWasm on GitHub Publication License: Community + MIT

Compile C# to WebAssembly · Try it in the browser · Install and build · See supported APIs · Read the documentation

C# now beats Rust on Wasm size

NetWasm + precise GC: 47,895 bytes
Rust 1.95.0 size-oriented profile: 53,635 bytes

For the same print-42 workload, NetWasm's result includes the runtime and precise Compact garbage collector. Both artifacts are standalone WASI Preview 2 Components, built the way a developer gets them out of the box: each toolchain's standard library and ordinary build, with no hand-added tools.

10.7% smaller raw. 19.5% smaller with Brotli-11.

Wasm footprint landscape with raw and Brotli-11 sizes. NetWasm with precise GC is 47,895 raw and 13,660 compressed bytes; Rust is 53,635 and 16,963; Kotlin/Wasm is 79,293 and 22,655; TinyGo is 93,043 and 26,931. NetWasm and Rust are the matched WASI Preview 2 comparison; Kotlin and TinyGo are contextual Preview 1 references.

Toolchain Raw Wasm Brotli 11 Comparison role
NetWasm, Compact GC 47,895 B 13,660 B WASI P2 Component; precise GC included
Rust 1.95.0, size profile 53,635 B 16,963 B Matched WASI P2 Component reference
Kotlin 2.4.0 wasmWasi 79,293 B 22,655 B P1 context; GC supplied by the host engine
TinyGo 0.39.0 93,043 B 26,931 B P1 context; precise GC configured

Rust is the headline comparison because it uses the same workload and output form. Kotlin/Wasm and TinyGo show the broader footprint landscape, but their targets and runtime boundaries differ. This is a measured workload/profile result, not a language-wide size ranking.

NetWasm's figure is the template application's default Release publish. Rust's adds Cargo's documented size settings (opt-level = "z", LTO, one codegen unit, panic = "abort" and stripped symbols) to an ordinary cargo build. Binaryen's wasm-opt is not a post-processing step here: it is part of NetWasm's compiler pipeline and runs in every ordinary build, with nothing to install or enable. Rust's wasm32-wasip2 output is a component, so applying wasm-opt to it means extracting the core module, optimizing it and re-encoding the component by hand.

Nội dung README thuộc về zion-sati và cộng đồng đóng góp, giấy phép Không có giấy phép. Nguồn: github.com/zion-sati/NetWasm