ProxyInterfaceGenerator 0.13.0
dotnet add package ProxyInterfaceGenerator --version 0.13.0
NuGet\Install-Package ProxyInterfaceGenerator -Version 0.13.0
<PackageReference Include="ProxyInterfaceGenerator" Version="0.13.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="ProxyInterfaceGenerator" Version="0.13.0" />
<PackageReference Include="ProxyInterfaceGenerator"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add ProxyInterfaceGenerator --version 0.13.0
#r "nuget: ProxyInterfaceGenerator, 0.13.0"
#:package ProxyInterfaceGenerator@0.13.0
#addin nuget:?package=ProxyInterfaceGenerator&version=0.13.0
#tool nuget:?package=ProxyInterfaceGenerator&version=0.13.0
ProxyInterfaceGenerator
This project uses Source Generation to generate an interface and a Proxy class for classes. This makes it possible to wrap external classes which do not have an interface, in a Proxy class which makes it easier to Mock and use DI.
It supports:
- properties
- methods
- events
- implicit and explicit operators
Info
Given: an external existing class which does not implement an interface
public sealed class Person
{
public string Name { get; set; }
public string HelloWorld(string name)
{
return $"Hello {name} !";
}
}
Create a partial interface
And annotate this with ProxyInterfaceGenerator.Proxy[...] and with the Type which needs to be wrapped:
[ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.Person))]
public partial interface IPerson
{
}
When the code is compiled, this source generator creates the following two items:
1. An additional partial interface Which defines the same properties and methods as in the external class.
public partial interface IPerson
{
string Name { get; set; }
string HelloWorld(string name);
}
2. A Proxy class Which takes the external class in the constructor and wraps all properties and methods.
public class PersonProxy : IPerson
{
public Person _Instance { get; }
public PersonProxy(Person instance)
{
_Instance = instance;
}
public string Name { get => _Instance.Name; set => _Instance.Name = value; }
public string HelloWorld(string name)
{
string name_ = name;
var result_19479959 = _Instance.HelloWorld(name_);
return result_19479959;
}
}
Use it
IPerson p = new PersonProxy(new Person());
p.Name = "test";
p.HelloWorld("stef");
Sponsors
Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of ProxyInterfaceSourceGenerator.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.13.0 | 60 | 8/30/2026 |
| 0.12.0 | 57 | 8/30/2026 |
| 0.11.0 | 870 | 9/5/2025 |
| 0.10.0 | 301 | 9/4/2025 |
| 0.9.1-preview-01 | 427 | 8/6/2025 |
| 0.9.0.1 | 490 | 6/13/2025 |
| 0.9.0 | 3,859 | 1/24/2025 |
| 0.8.1 | 292 | 1/20/2025 |
| 0.8.0 | 267 | 1/14/2025 |
| 0.5.0 | 322 | 1/6/2025 |
| 0.4.0 | 487 | 9/30/2024 |
| 0.3.0 | 321 | 9/24/2024 |
| 0.2.0 | 312 | 9/23/2024 |
| 0.1.0 | 409 | 4/28/2024 |
| 0.0.38 | 333 | 4/23/2024 |
| 0.0.37 | 564 | 12/6/2023 |
| 0.0.36 | 461 | 10/10/2023 |
| 0.0.35 | 501 | 3/2/2023 |
# 0.13.0 (30 August 2026)
- #95 Support NullableAnnotation.None [enhancement]
The full release notes can be found here: https://github.com/StefH/ProxyInterfaceSourceGenerator/blob/main/ReleaseNotes.md

