NanoProxy 0.3.6
dotnet add package NanoProxy --version 0.3.6
NuGet\Install-Package NanoProxy -Version 0.3.6
<PackageReference Include="NanoProxy" Version="0.3.6" />
<PackageVersion Include="NanoProxy" Version="0.3.6" />
<PackageReference Include="NanoProxy" />
paket add NanoProxy --version 0.3.6
#r "nuget: NanoProxy, 0.3.6"
#:package NanoProxy@0.3.6
#addin nuget:?package=NanoProxy&version=0.3.6
#tool nuget:?package=NanoProxy&version=0.3.6
NanoProxy
NanoProxy is a lightweight, high-performance .NET library for generating runtime proxies that intercept property setters. It enables scenarios such as change tracking, validation, logging, and auditing without modifying your original class code.
Features
- Dynamic Proxy Generation - Uses
System.Reflection.Emitfor efficient runtime proxy creation - Property Setter Interception - Captures both old and new values on property changes
- Type Support - Works with value types, nullable types, and reference types (strings, objects)
- Thread-Safe - Built-in thread-safe proxy type caching for optimal performance
- Zero Dependencies - Lightweight library with no external dependencies
- Virtual Property Override - Leverages inheritance to intercept virtual property setters
- .NET 8 Compatible - Built for modern .NET applications
Installation
Install NanoProxy via NuGet Package Manager:
dotnet add package NanoProxy
Usage Example
Suppose you have a class (currently parameterless constructor is required):
public class TestClass
{
public virtual int IntegerProperty { get; set; }
public virtual int? NullableIntegerProperty { get; set; }
public virtual string StringProperty { get; set; }
}
You can create a proxy and intercept virtual property changes:
var builder = new NanoProxy.NanoProxyBuilder();
var proxy = builder.CreateProxy<TestClass>();
proxy.Interceptor = (value, oldValue, propertyInfo) =>
{
Console.WriteLine($"Property '{propertyInfo}' changed from '{oldValue}' to '{value}'");
};
proxy.WrapedObject.NullableIntegerProperty = 42; // Property 'NullableIntegerProperty' changed from '' to '42'
proxy.WrapedObject.NullableIntegerProperty = 2; /// Property 'NullableIntegerProperty' changed from '42' to '2'
Where interceptor is defined as:
public delegate void SetInterceptor(object value, object oldValue, PropertyInfo propertyInfo);
Testing
NanoProxy includes NUnit-based tests. To run them:
- Open the solution in Visual Studio 2022.
- Build the solution.
- Use Test Explorer to run all tests.
Requirements
- .NET 8.0 or later
- Visual Studio 2022 or compatible IDE
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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 Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- 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.