WACS.HostBindings.SourceGen 0.1.1

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

WACS.HostBindings.SourceGen

Roslyn source generator that auto-generates the IImports adapter for a transpiled wasm module's host functions, using [WacsImport]-annotated static methods discovered in the consumer's compilation references.

What it does

For every [assembly: WacsTranspiledImports(typeof(T))] attribute the generator finds across the compilation:

  1. Scans referenced assemblies for [WacsImport(module, name)] static methods.
  2. Pairs each method on the IImports interface with its matching binding (by wasm import name).
  3. Emits a GeneratedHostImports : IImports partial class whose method bodies forward to the matched bindings.
  4. Threads any binding-required shared-state parameters (e.g. Wacs.WASI.Preview1.State) through a constructor.

If no binding is found for an import, the generator emits a WACS001 error diagnostic so the compile fails with a clear message rather than at runtime.

Diagnostics

  • WACS001 (error): no binding found for <module>.<name>
  • WACS002 (error): binding signature mismatch
  • WACS003 (error): multiple bindings registered (ambiguous)
  • WACS004 (info): matched binding (verbose; off by default)

Consumer usage

Add the generator alongside your binding package(s):

<ItemGroup>
  <Reference Include="MyTranspiledApp" HintPath="MyTranspiledApp.dll" />
  <PackageReference Include="WACS.WASI.Preview1" />
  <PackageReference Include="WACS.HostBindings.SourceGen" />
</ItemGroup>

Then in your code:

var state = new Wacs.WASI.Preview1.State { /* ... */ };
var imports = new MyTranspiledApp.WacsGenerated.GeneratedHostImports(state)
{
    MemoryProvider = () => GetWasmMemoryView(),  // wire to your runtime
};
var module = new MyTranspiledApp.Module(imports);
module._start();

wacs aot wires the package reference + memory provider for you; the manual setup above is for embedders who construct the host process by hand.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 102 5/28/2026
0.1.0 94 5/1/2026