Ling.Interceptors
1.1.0
dotnet add package Ling.Interceptors --version 1.1.0
NuGet\Install-Package Ling.Interceptors -Version 1.1.0
<PackageReference Include="Ling.Interceptors" Version="1.1.0" />
<PackageVersion Include="Ling.Interceptors" Version="1.1.0" />
<PackageReference Include="Ling.Interceptors" />
paket add Ling.Interceptors --version 1.1.0
#r "nuget: Ling.Interceptors, 1.1.0"
#:package Ling.Interceptors@1.1.0
#addin nuget:?package=Ling.Interceptors&version=1.1.0
#tool nuget:?package=Ling.Interceptors&version=1.1.0
Ling.Interceptors
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
| Product | Versions 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. |
-
.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.