Allors.Immersive 2.1.10-preview

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

Immersive

Allors.Immersive Allors.Immersive.Attributes Allors.Immersive.MSBuild Allors.Immersive.Tool Allors.Immersive.Winforms

Immerse a library inside another library.

Immersive is an IL weaver that substitutes types and methods from a referenced assembly with implementations from an "immerse" assembly. At compile time, it rewrites IL so that the target assembly uses the substitute types and method bodies — without changing source code.

Installation

Automatically weaves your assembly after compilation:

dotnet add package Allors.Immersive.MSBuild

CLI tool

For standalone weaving from the command line:

dotnet tool install -g Allors.Immersive.Tool

Individual packages

dotnet add package Allors.Immersive              # Weaving engine API
dotnet add package Allors.Immersive.Attributes   # SubstituteClass/SubstituteMethod attributes
dotnet add package Allors.Immersive.Winforms     # WinForms substitute types and testers

How it works

Three assemblies are involved:

  1. Referenced assembly — the library your code depends on (e.g. AssemblyReferenced)
  2. Immerse assembly — provides substitute types/methods annotated with [SubstituteClass] and [SubstituteMethod] (e.g. AssemblyToImmerse)
  3. Target assembly — your project that references both; after weaving, all references to types in the referenced assembly are rewritten to use the substitutes

The target assembly signals which immerse assembly to use via a marker class:

#if(DEBUG)
public class ImmersiveMarker : AssemblyToImmerse.Marker
{
}
#endif

The weaver discovers the immerse assembly from the marker's base type, then rewrites the target's IL accordingly.

Usage

MSBuild task (automatic)

Reference the Allors.Immersive.MSBuild package in your project. It includes a .targets file that runs the weaver automatically after compilation:

<Target Name="Immersive" AfterTargets="Compile">
  <ImmersiveTask AssemblyPath="$(TargetPath)" SearchDirectories="@(ReferencePath)" />
</Target>

CLI tool

immerse <assembly-path> [options]

Arguments:
  <assembly-path>            Path to the assembly to weave

Options:
  -s, --search-dir <dir>     Search directory for assemblies (repeatable)
  -v, --verbose              Print weaver info messages
  -h, --help                 Show this help

If no search directories are specified, the directory containing the assembly is used.

Attributes

The Allors.Immersive.Attributes package provides two attributes for the immerse assembly.

[SubstituteClass]

Applied to a class in the immerse assembly. Two modes:

Base substitution — no arguments. The class to substitute is inferred from the base type:

[SubstituteClass]
public class Form : AssemblyReferenced.Form
{
    // All references to AssemblyReferenced.Form in the target
    // will be rewritten to use this type's members
}

Explicit substitution — pass the type to substitute:

[SubstituteClass(typeof(AssemblyReferenced.Button))]
public class MyButton
{
    // Substitutes AssemblyReferenced.Button
}

[SubstituteMethod]

Applied to a method. Substitutes a specific method on a specific type:

[SubstituteMethod(typeof(AssemblyReferenced.Form), "ShowDialog")]
public string AllorsShowDialog()
{
    return "Substitute: " + ShowDialog();
}

The first argument is the type containing the method to substitute. The second (optional) argument is the method name — if omitted, the decorated method's own name is used.

Example

AssemblyReferenced (the library):

public class Form
{
    public string ShowDialog() => "Referenced: ShowDialog()";
}

AssemblyToImmerse (the substitutions):

[SubstituteClass]
public class Form : AssemblyReferenced.Form
{
    [SubstituteMethod(typeof(AssemblyReferenced.Form), "ShowDialog")]
    public string AllorsShowDialog()
    {
        return "Substitute: " + ShowDialog();
    }
}

AssemblyToProcess (the target — before weaving):

public class TestForm : AssemblyReferenced.Form
{
    public string CallShowDialog() => this.ShowDialog();
}

After weaving, TestForm inherits from the substitute Form and CallShowDialog() invokes the substituted method body.

Building

The project uses Nuke as its build system.

./build.cmd Compile        # restore + build
./build.cmd Test           # run tests
./build.cmd Pack           # create NuGet packages in output/
./build.cmd Clean Compile  # clean then build

Solution structure

Project Description
src/Allors.Immersive Weaving engine (dnlib-based IL rewriting) — standalone NuGet package
src/Allors.Immersive.Attributes Attribute definitions (SubstituteClassAttribute, SubstituteMethodAttribute)
src/Allors.Immersive.MSBuild MSBuild task that invokes the weaver after compilation
src/Allors.Immersive.Tool CLI global tool for standalone weaving
src/Allors.Immersive.Winforms WinForms substitute types and testers
test/AssemblyReferenced Test fixture — the referenced library
test/AssemblyToImmerse Test fixture — substitute implementations
test/AssemblyToProcess Test fixture — target assembly to weave
test/Tests Integration tests validating the weaving results

License

LGPL-3.0

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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 Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

  • net10.0

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
2.1.10-preview 78 2/12/2026
2.1.9-preview 70 2/11/2026
2.1.7-preview 66 2/10/2026