ProxyInterfaceGenerator 0.0.26
See the version list below for details.
dotnet add package ProxyInterfaceGenerator --version 0.0.26
NuGet\Install-Package ProxyInterfaceGenerator -Version 0.0.26
<PackageReference Include="ProxyInterfaceGenerator" Version="0.0.26"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="ProxyInterfaceGenerator" Version="0.0.26" />
<PackageReference Include="ProxyInterfaceGenerator"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add ProxyInterfaceGenerator --version 0.0.26
#r "nuget: ProxyInterfaceGenerator, 0.0.26"
#addin nuget:?package=ProxyInterfaceGenerator&version=0.0.26
#tool nuget:?package=ProxyInterfaceGenerator&version=0.0.26
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");
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.9.0 | 112 | 1/24/2025 |
0.8.1 | 106 | 1/20/2025 |
0.8.0 | 87 | 1/14/2025 |
0.5.0 | 116 | 1/6/2025 |
0.4.0 | 144 | 9/30/2024 |
0.3.0 | 131 | 9/24/2024 |
0.2.0 | 102 | 9/23/2024 |
0.1.0 | 216 | 4/28/2024 |
0.0.38 | 132 | 4/23/2024 |
0.0.37 | 343 | 12/6/2023 |
0.0.36 | 330 | 10/10/2023 |
0.0.35 | 357 | 3/2/2023 |
0.0.34 | 270 | 2/25/2023 |
0.0.31 | 288 | 2/21/2023 |
0.0.30 | 455 | 1/23/2023 |
0.0.29 | 278 | 1/9/2023 |
0.0.28 | 333 | 1/8/2023 |
0.0.27 | 365 | 12/17/2022 |
0.0.26 | 312 | 12/14/2022 |
0.0.25 | 348 | 12/13/2022 |
0.0.24 | 3,746 | 9/5/2022 |
0.0.23 | 419 | 9/4/2022 |
0.0.22 | 546 | 5/9/2022 |
0.0.21 | 478 | 5/8/2022 |
0.0.20 | 421 | 5/8/2022 |
0.0.19 | 471 | 5/8/2022 |
0.0.18 | 471 | 5/8/2022 |
0.0.17 | 476 | 5/7/2022 |
0.0.16 | 491 | 5/6/2022 |
0.0.15 | 479 | 2/6/2022 |
0.0.14 | 510 | 2/4/2022 |
0.0.13 | 484 | 2/2/2022 |
0.0.12 | 499 | 2/1/2022 |
0.0.11 | 402 | 8/10/2021 |
0.0.10 | 441 | 8/6/2021 |
0.0.9 | 357 | 8/5/2021 |
0.0.8 | 389 | 8/3/2021 |
0.0.6 | 424 | 8/1/2021 |
0.0.5 | 453 | 7/31/2021 |
0.0.4 | 392 | 7/28/2021 |
0.0.3 | 433 | 7/25/2021 |
0.0.2 | 369 | 7/25/2021 |
0.0.1 | 413 | 7/25/2021 |
# 0.0.26 (14 December 2022)
- #46 Add support to generate code for interface without a namespace [enhancement]
- #47 Only generate setters and getters for public properties [bug]
- #42 Build error on missing namespace [bug]
- #44 Build error on mixed visibility properties [bug]
The full release notes can be found here: https://github.com/StefH/ProxyInterfaceSourceGenerator/blob/main/ReleaseNotes.md