ProxyInterfaceGenerator 0.0.16

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

Usage

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");
There are no supported framework assets in this package.

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.11.0 108 9/5/2025
0.10.0 143 9/4/2025
0.9.1-preview-01 325 8/6/2025
0.9.0.1 335 6/13/2025
0.9.0 828 1/24/2025
0.8.1 147 1/20/2025
0.8.0 133 1/14/2025
0.5.0 174 1/6/2025
0.4.0 199 9/30/2024
0.3.0 167 9/24/2024
0.2.0 149 9/23/2024
0.1.0 256 4/28/2024
0.0.38 172 4/23/2024
0.0.37 393 12/6/2023
0.0.36 364 10/10/2023
0.0.35 400 3/2/2023
0.0.34 315 2/25/2023
0.0.31 333 2/21/2023
0.0.30 504 1/23/2023
0.0.29 325 1/9/2023
0.0.28 375 1/8/2023
0.0.27 428 12/17/2022
0.0.26 368 12/14/2022
0.0.25 394 12/13/2022
0.0.24 3,855 9/5/2022
0.0.23 464 9/4/2022
0.0.22 601 5/9/2022
0.0.21 540 5/8/2022
0.0.20 479 5/8/2022
0.0.19 525 5/8/2022
0.0.18 524 5/8/2022
0.0.17 540 5/7/2022
0.0.16 548 5/6/2022
0.0.15 536 2/6/2022
0.0.14 569 2/4/2022
0.0.13 541 2/2/2022
0.0.12 557 2/1/2022
0.0.11 475 8/10/2021
0.0.10 517 8/6/2021
0.0.9 414 8/5/2021
0.0.8 453 8/3/2021
0.0.6 487 8/1/2021
0.0.5 531 7/31/2021
0.0.4 452 7/28/2021
0.0.3 492 7/25/2021
0.0.2 433 7/25/2021
0.0.1 473 7/25/2021

# 0.0.16 (06 May 2022)
- #31 Fix for Explicit DefaultValue is not defined [bug]

The full release notes can be found here: https://github.com/StefH/ProxyInterfaceSourceGenerator/blob/main/ReleaseNotes.md