WACS.WASIp1 0.9.7

dotnet add package WACS.WASIp1 --version 0.9.7
                    
NuGet\Install-Package WACS.WASIp1 -Version 0.9.7
                    
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.WASIp1" Version="0.9.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WACS.WASIp1" Version="0.9.7" />
                    
Directory.Packages.props
<PackageReference Include="WACS.WASIp1" />
                    
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.WASIp1 --version 0.9.7
                    
#r "nuget: WACS.WASIp1, 0.9.7"
                    
#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.WASIp1@0.9.7
                    
#: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.WASIp1&version=0.9.7
                    
Install as a Cake Addin
#tool nuget:?package=WACS.WASIp1&version=0.9.7
                    
Install as a Cake Tool

WACS.WASIp1 for WACS

A C# implementation of WASI preview 1 for the WACS WebAssembly Interpreter.

Installation

Add the assembly from NuGet:

dotnet add package WACS.WASIp1

Usage Example

Here's a basic example demonstrating how to bind WASIp1 to the WACS WebAssembly runtime:

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using Wacs.Core;
using Wacs.Core.Runtime;
using Wacs.Core.WASIp1;
using Wacs.WASIp1.Types;

var runtime = new WasmRuntime();
var wasiConfig = new WasiConfiguration() {
    StandardInput = System.Console.OpenStandardInput(),
    StandardOutput = System.Console.OpenStandardOutput(),
    StandardError = System.Console.OpenStandardError(),
    
    Arguments = Environment.GetCommandLineArgs()
        .Skip(1)
        .ToList(),
    
    EnvironmentVariables = Environment.GetEnvironmentVariables()
        .Cast<DictionaryEntry>()
        .ToDictionary(de => de.Key.ToString()!, de => de.Value?.ToString()??""),
    
    HostRootDirectory = Directory.GetCurrentDirectory(),
};
var wasi = new WASIp1.Wasi(wasiConfig);
wasi.BindToRuntime(runtime);

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

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

if (runtime.TryGetExportedFunction(("mymodule", "main"), out var mainAddr))
{
    try
    {
        var mainInvoker = runtime.CreateInvoker<Func<Value>>(mainAddr);
        int result = mainInvoker();
        Console.Error.WriteLine($"mymodule.main() => {result}");
    }
    catch (TrapException exc)
    {
        System.Console.Error.WriteLine(exc);
        return 1;
    }
    catch (SignalException exc)
    {
        System.Console.Error.WriteLine($"{exc.HumanReadable}");
        return exc.Signal;
    }
}

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.
  • .NETStandard 2.1

  • net8.0

NuGet packages (1)

Showing the top 1 NuGet packages that depend on WACS.WASIp1:

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

GitHub repositories (1)

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

Repository Stars
6over3/hako
An embeddable, lightweight, secure, high-performance JavaScript engine.
Version Downloads Last Updated
0.9.7 443 2/6/2025
0.9.6 164 12/15/2024
0.9.3 159 11/26/2024
0.9.2 149 11/26/2024
0.9.1 155 11/14/2024
0.9.0 144 11/13/2024