Splice 0.0.1-rc2

This is a prerelease version of Splice.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Splice --version 0.0.1-rc2
                    
NuGet\Install-Package Splice -Version 0.0.1-rc2
                    
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="Splice" Version="0.0.1-rc2">
  <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="Splice" Version="0.0.1-rc2" />
                    
Directory.Packages.props
<PackageReference Include="Splice">
  <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 Splice --version 0.0.1-rc2
                    
#r "nuget: Splice, 0.0.1-rc2"
                    
#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 Splice@0.0.1-rc2
                    
#: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=Splice&version=0.0.1-rc2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Splice&version=0.0.1-rc2&prerelease
                    
Install as a Cake Tool

Splice 🚀

GitHub License GitHub Actions Workflow Status

A C# .NET solution focused on Roslyn Source Generators, specifically implementing C# 14 "Interceptors". This framework allows you to easily intercept and replace method calls at compile time.

Quick Start 🏁

1. Installation 📦

Add the Splice as a source generator to your project. If you are using NuGet:

dotnet add package Splice

2. Project Configuration ⚙️

Interceptors are a C# 11+ feature (fully matured in C# 14). You need to enable them in your .csproj (C# 12+ required for basic support, C# 14 for full stability):

<PropertyGroup>
  
  <LangVersion>preview</LangVersion>
  
  
  <InterceptorsNamespaces>$(InterceptorsNamespaces);MyProject.Interceptors</InterceptorsNamespaces>
  
  
  <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>

How to Use 🛠️

Create an Interceptor

To intercept a method, create a partial class and a partial method decorated with the [Interceptor] attribute.

using System;
using Generators; // Namespace for the [Interceptor] attribute

namespace MyProject.Interceptors;

public static partial class MyInterceptor
{
    // Intercept Console.WriteLine(string) calls
    [Interceptor(typeof(Console), nameof(Console.WriteLine))]
    public static partial void WriteLine(string? message)
    {
        // NOTE: Calls to the intercepted method within its OWN body are NOT intercepted.
        // However, if this method calls ANOTHER method that then calls Console.WriteLine,
        // ⚠️ you might run into infinite recursion!
        Console.WriteLine($"[Intercepted] {message}");
    }
}

Attribute Variations

The framework provides two ways to specify the target method:

<details> <summary><b>1. Type-based (Recommended for non-generic targets)</b></summary>

[Interceptor(typeof(TargetType), "MethodName")]

</details>

<details> <summary><b>2. Generic-based (Clean syntax)</b></summary>

[Interceptor<TargetType>("MethodName")]

</details>


Configuration Details ⚙️

The InterceptorsNamespaces Property

The C# compiler requires you to explicitly list the namespaces that are allowed to contain interceptors for security and performance reasons.

If your interceptor is in MyProject.Interceptors, you must add that namespace to the <InterceptorsNamespaces> property in your .csproj. You can add multiple namespaces separated by semicolons.

<InterceptorsNamespaces>$(InterceptorsNamespaces);Namespace1;Namespace2</InterceptorsNamespaces>

Features ✨

  • Core Interceptor Source Generator: Automatically maps interceptors to their call sites.
  • Recursion Protection: Prevents an interceptor from intercepting itself (only within its own method body).
  • Sample project: Real-world demonstration of interception.
  • Comprehensive test suite: Using xUnit v3 to ensure stability.

Automated Workflows 🤖

Continuous Integration (CI)

The project uses GitHub Actions to automatically build and test every push and pull request targeting the main branch.

Continuous Deployment (CD)

Releases are automated via GitHub Actions. Pushing a tag matching v* (e.g., v1.0.0) triggers:

  1. Automated build and test.
  2. Creation of a GitHub Release with build artifacts.
  3. Publishing the package to NuGet.org.

Note: To publish to NuGet, a NUGET_API_KEY must be configured in the repository's GitHub Secrets.

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 was computed.  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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.

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.0.2 94 3/26/2026
0.0.1 97 3/17/2026
0.0.1-rc3 97 3/16/2026
0.0.1-rc2 94 3/16/2026
0.0.1-rc1 95 3/16/2026