Ling.Interceptors 1.1.0

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

Ling.Interceptors

Project documentation | 简体中文

Ling.Interceptors provides the public interception and monitoring API, plus bundled Roslyn analyzer and incremental source generator. It requires .NET SDK 9.0.200 or later.

Installation

dotnet add package Ling.Interceptors

The package automatically configures Ling.Interceptors.Generated in InterceptorsNamespaces.

Monitor calls

[Monitor(CaptureParameters = true, CaptureReturnValue = true)]
[return: SensitiveData]
public async Task<Order> PlaceOrder(
    int customerId,
    [SensitiveData] string product)
{
    // implementation
}

The generator discovers calls in the current compilation and emits a wrapper that records the selected values, exceptions, and elapsed time. Configure a sink explicitly:

MonitorRuntime.Sink = new LoggerMonitorSink(loggerFactory);

The default formatter preserves scalar values, masks sensitive values, and emits a declared-type summary for other objects without calling ToString() or serializing them. Replace MonitorRuntime.Formatter for custom structured output; its MonitorValueContext identifies sensitive values.

Both an assembly that declares monitored APIs and a project that contains monitored call sites need this package.

Define a replacement

using Ling.Interceptors;

internal static class Replacements
{
    [Intercept("trace", nameof(Service.Send),
        InterceptionScope.Explicit | InterceptionScope.Compilation)]
    internal static void Send(Service service, string value)
    {
        Console.WriteLine($"trace:{value}");
        service.Send(value); // Replacement bodies call the original implementation.
    }
}

The target must use qualified nameof(T.Method). The replacement must be an accessible static method with a compatible signature; instance targets add the receiver as the first parameter.

Select calls

service./* intercept:trace */Send("one"); // Explicit rule
service.Send("two");                      // Compilation rule

Explicit enables an annotated call site. Compilation matches ordinary calls in the current project. GeneratedCode must be combined with Compilation; it covers recognized generated code and enables the package's command-line two-phase compilation when another source generator emits matching calls.

Diagnostics and limits

The included analyzer reports invalid IDs/scopes, malformed nameof expressions, inaccessible or incompatible replacements, ambiguous targets, invalid markers, conflicting compilation rules, and Monitor/interceptor conflicts. Constructors, properties, operators, delegate invocation, and method-group conversions are unsupported. Monitor wrappers support ordinary returns, Task, Task<T>, ValueTask, and ValueTask<T>.

License

MIT

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.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Ling.Interceptors:

Package Downloads
Ling.Interceptors.OpenTelemetry

OpenTelemetry-compatible tracing and metrics sink for Ling.Interceptors.

Ling.Interceptors.Logging

Microsoft.Extensions.Logging integration for Ling.Interceptors monitoring.

Ling.Interceptors.Console

Console monitoring sink for Ling.Interceptors.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 195 9/3/2026
1.0.0 96 9/2/2026