ProxyInterfaceGenerator 0.0.35

There is a newer version of this package available.
See the version list below for details.
dotnet add package ProxyInterfaceGenerator --version 0.0.35
NuGet\Install-Package ProxyInterfaceGenerator -Version 0.0.35
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.35">
  <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.
paket add ProxyInterfaceGenerator --version 0.0.35
#r "nuget: ProxyInterfaceGenerator, 0.0.35"
#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.
// Install ProxyInterfaceGenerator as a Cake Addin
#addin nuget:?package=ProxyInterfaceGenerator&version=0.0.35

// Install ProxyInterfaceGenerator as a Cake Tool
#tool nuget:?package=ProxyInterfaceGenerator&version=0.0.35

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.0.38 70 4/23/2024
0.0.37 282 12/6/2023
0.0.36 290 10/10/2023
0.0.35 332 3/2/2023
0.0.34 244 2/25/2023
0.0.31 245 2/21/2023
0.0.30 408 1/23/2023
0.0.29 250 1/9/2023
0.0.28 295 1/8/2023
0.0.27 314 12/17/2022
0.0.26 281 12/14/2022
0.0.25 317 12/13/2022
0.0.24 2,677 9/5/2022
0.0.23 389 9/4/2022
0.0.22 498 5/9/2022
0.0.21 430 5/8/2022
0.0.20 389 5/8/2022
0.0.19 436 5/8/2022
0.0.18 424 5/8/2022
0.0.17 443 5/7/2022
0.0.16 442 5/6/2022
0.0.15 428 2/6/2022
0.0.14 459 2/4/2022
0.0.13 420 2/2/2022
0.0.12 459 2/1/2022
0.0.11 364 8/10/2021
0.0.10 391 8/6/2021
0.0.9 321 8/5/2021
0.0.8 338 8/3/2021
0.0.6 388 8/1/2021
0.0.5 399 7/31/2021
0.0.4 342 7/28/2021
0.0.3 386 7/25/2021
0.0.2 333 7/25/2021
0.0.1 364 7/25/2021

# 0.0.35 (02 March 2023)
- #61 Fix &quot;ref&quot; parameter [bug]
- #60 Parameters passed in with Keyword &quot;ref&quot; are proxied such that they are no longer updated by reference [bug]

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