Owlcat.GenericDetours 0.1.0-alpha.18

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

Owlcat.GenericDetours

Owlcat.GenericDetours detours open generic methods in Owlcat Unity games without deploying assemblies named MonoMod.* or Mono.Cecil.*. Its implementation dependencies are internalized into this assembly, so loading it does not replace the MonoMod version used by HarmonyX or another mod.

The library targets .NET Framework 3.5 for compatibility with older Unity Mono runtimes and can be referenced by the net472 and net481 projects produced by Owlcat.Templates.

Install the prerelease package with:

dotnet add package Owlcat.GenericDetours --version 0.1.0-alpha.17

Usage

using Owlcat.RuntimeDetour;
using System;
using System.Reflection;

static class Example
{
    private static T Identity<T>(T value) => value;

    private static T Replacement<T>(Func<T, T> orig, T value)
    {
        // Call orig(value), replace the result, or both.
        return orig(value);
    }

    public static GenericDetour Install()
    {
        const BindingFlags Flags = BindingFlags.NonPublic | BindingFlags.Static;
        var source = typeof(Example).GetMethod(nameof(Identity), Flags);
        var target = typeof(Example).GetMethod(nameof(Replacement), Flags);

        return new GenericDetour(
            source,
            target,
            new[] { new[] { typeof(string) } });
    }
}

Keep the returned GenericDetour alive for as long as the patch is needed and dispose it when the mod unloads. Use Prime to add instantiations discovered later.

Automatic discovery is optional. Explicit priming is the predictable default and bypasses discovery, but it does not bypass the runtime-specific dispatch machinery. In particular, Mono generic contexts that are not carried by this currently require x86-64 or Arm64, and Mono builds using the alternative MONO_SMALL_CONFIG generic-metadata layout are not supported. Some explicitly primed hooks do not need those paths and can still work elsewhere.

Isolation boundary

Managed assembly loading is isolated: the package contains only Owlcat.GenericDetours.dll, and its implementation types are internal. Native patches are process-wide. Do not patch the same concrete method body with this library and another detour engine concurrently; neither engine can preserve the other's private detour chain.

Product Compatible and additional computed target framework versions.
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 3.5

    • 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.0-alpha.18 76 8/27/2026
0.1.0-alpha.17 84 8/13/2026
0.1.0-alpha.10 71 8/13/2026
0.1.0-alpha.9 78 8/13/2026
0.1.0-alpha.8 69 8/13/2026
0.1.0-alpha.7 70 8/13/2026
0.1.0-alpha.6 68 8/13/2026
0.1.0-alpha.5 69 8/13/2026
0.1.0-alpha.4 72 8/13/2026
0.1.0-alpha.3 72 8/13/2026
0.1.0-alpha.2 69 8/13/2026
0.1.0-alpha.1 73 8/13/2026