VOOZH about

URL: https://www.nuget.org/packages/WACS.WASI.Preview2.DependencyInjection/

⇱ NuGet Gallery | WACS.WASI.Preview2.DependencyInjection 0.3.0




WACS.WASI.Preview2.DependencyInjection 0.3.0

dotnet add package WACS.WASI.Preview2.DependencyInjection --version 0.3.0
 
 
NuGet\Install-Package WACS.WASI.Preview2.DependencyInjection -Version 0.3.0
 
 
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.WASI.Preview2.DependencyInjection" Version="0.3.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WACS.WASI.Preview2.DependencyInjection" Version="0.3.0" />
 
Directory.Packages.props
<PackageReference Include="WACS.WASI.Preview2.DependencyInjection" />
 
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.WASI.Preview2.DependencyInjection --version 0.3.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: WACS.WASI.Preview2.DependencyInjection, 0.3.0"
 
 
#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.WASI.Preview2.DependencyInjection@0.3.0
 
 
#: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.WASI.Preview2.DependencyInjection&version=0.3.0
 
Install as a Cake Addin
#tool nuget:?package=WACS.WASI.Preview2.DependencyInjection&version=0.3.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

WACS.WASI.Preview2.DependencyInjection

Microsoft.Extensions.DependencyInjection extensions for WACS.WASI.Preview2. One-call registration of every WASI 0.2.3 subsystem default + a pre-wired Linker.

Component-mode WASI Preview 2 hosts assemble a lot of moving pieces — typed [WitSource] interfaces per subsystem, the resource-handle registry, the Linker that fires every *Bindings.BindToRuntime, the composite bundle that exposes Preview 2 + WASI.NN through one CLR object. This package wires it all in idiomatic .NET DI form.

Install

dotnet add package WACS.WASI.Preview2.DependencyInjection

Quick start — WasiPreview2RuntimeScope (one-shot embedder)

The simplest path: one disposable that owns the DI scope, fires every binding's BindToRuntime, and resolves the composite bundle.

using Wacs.Core.Runtime;
using Wacs.WASI.Preview2.DependencyInjection;

var runtime = new WasmRuntime();
using var wasi = new WasiPreview2RuntimeScope(
 runtime,
 preopens: new[] { ("./models", "/models") });

// wasi.Bundle → composite hostBundle
// (Preview2 + WASI.NN forwarding when the
// WASI.NN.DependencyInjection sibling is on
// the load path)
// wasi.Resources → single resource registry across subsystems
// wasi.Runtime → runtime, with every wasi:* binding wired

// ... transpile the component, instantiate, invoke ...

WasiPreview2RuntimeScope is what wacs run --wasip2 uses internally. It auto-discovers Wacs.WASI.NN.DependencyInjection when present and registers the WasiPreview2NNBundle composite — no extra config when chaining wasi-nn alongside.

Quick start — IServiceCollection

For ASP.NET, generic-host worker services, or anywhere with an existing DI container:

using Microsoft.Extensions.DependencyInjection;
using Wacs.WASI.Preview2.DependencyInjection;

var services = new ServiceCollection();
services.AddWasiPreview2(); // every WASI 0.2.3 subsystem default registered

// Override individual subsystems via DI's normal TryAdd semantics:
services.AddSingleton<IOutgoingHandler>(_ =>
 new HttpClientOutgoingHandler(new HttpClient { Timeout = ... }));
services.AddSingleton<IEnvironment>(_ =>
 new SandboxedEnvironment(envVars: ..., args: ..., cwd: ...));

using var sp = services.BuildServiceProvider();
using var scope = sp.CreateScope();

var linker = scope.ServiceProvider.GetRequiredService<Linker>();
// linker.Runtime is the WasmRuntime with every wasi:* import bound

AddWasiPreview2(opts => opts.InstanceLifetime = ServiceLifetime.Scoped) is the default — fits ASP.NET request-scoped wasm execution. Pass Transient for per-call construction or Singleton for single-component apps.

Composing with WASI.NN

When WACS.WASI.NN.DependencyInjection is on the load path, the runtime scope auto-discovers it and registers the WasiPreview2NNBundle composite that forwards both Preview 2 and WASI.NN [WitSource] interface properties through one CLR object. The transpiler's direct-link IL casts to the composite type at the import call site; this package's auto-detection guarantees the expected type is present without any extra config.

What's included

  • Default impls for every WASI 0.2.3 subsystem: cli / clocks / filesystem / http / io / random / sockets
  • WasiPreview2Bundle (single-package) and WasiPreview2NNBundle (composite) bundle types
  • WasiPreview2Resources — the canonical resource registry direct-link emit looks up
  • WasiPreview2RuntimeScope — one-shot scope owning DI lifecycle, Linker resolution, and composite-bundle discovery

Documentation

  • docs/COMPONENT_CHAINING.md — runtime requirements, host-package composition, end-to-end CLI / embedder examples
  • Sibling package WACS.WASI.Preview2's README for manual subsystem wiring (no DI), per-impl override patterns

License

Apache-2.0

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 netstandard2.1 is compatible. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on WACS.WASI.Preview2.DependencyInjection:

Package Downloads
WACS.WASI.NN.DependencyInjection

Microsoft.Extensions.DependencyInjection extension methods for WACS.WASI.NN. Registers the WasiNNBundle that the transpiler's HostPackageResolver direct-links wasi:nn imports against — symmetric with WACS.WASI.Preview2.DependencyInjection. Tracks the wasi-nn proposal at WASI Phase 2 — the WIT surface may change as the proposal evolves.

WACS.WASI.GFX.DependencyInjection

Microsoft.Extensions.DependencyInjection extension methods for WACS.WASI.GFX. Registers the WasiGfxBundle that the transpiler's HostPackageResolver will direct-link wasi-gfx imports against — symmetric with WACS.WASI.NN.DependencyInjection and WACS.WASI.Preview2.DependencyInjection. 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.

Version Downloads Last Updated
0.3.0 159 5/28/2026
0.2.2 104 5/16/2026
0.2.0 99 5/12/2026
0.1.8 146 5/11/2026
0.1.6 104 5/10/2026
0.1.5 139 5/10/2026
0.1.2 139 5/10/2026
0.1.1 105 5/9/2026
0.1.0 105 5/1/2026