BeaKona.AutoInterfaceGenerator
1.0.46
dotnet add package BeaKona.AutoInterfaceGenerator --version 1.0.46
NuGet\Install-Package BeaKona.AutoInterfaceGenerator -Version 1.0.46
<PackageReference Include="BeaKona.AutoInterfaceGenerator" Version="1.0.46" />
<PackageVersion Include="BeaKona.AutoInterfaceGenerator" Version="1.0.46" />
<PackageReference Include="BeaKona.AutoInterfaceGenerator" />
paket add BeaKona.AutoInterfaceGenerator --version 1.0.46
#r "nuget: BeaKona.AutoInterfaceGenerator, 1.0.46"
#:package BeaKona.AutoInterfaceGenerator@1.0.46
#addin nuget:?package=BeaKona.AutoInterfaceGenerator&version=1.0.46
#tool nuget:?package=BeaKona.AutoInterfaceGenerator&version=1.0.46
AutoInterface
C# Source Generator which redirects all interface-calls to one or more backing members. Source code can be generated for a class, record, or struct. It can be generated automatically or by a custom template (scriban, liquid).
<br />
Manually written source:
interface IPrintable
{
void Print();
}
public partial class Person : IPrintable
{
[BeaKona.AutoInterface]
private readonly IPrintable aspect1 = new PersonPrinterV1();
}
Auto-generated accompanying source:
partial class Person
{
void IPrintable.Print() => this.aspect1.Print();
}
<br />
Ad-hoc adapter pattern
In this example PersonPrinterV1 does not implement IPrintable but does have all members that are required by that interface.
Manually written source:
interface IPrintable
{
void Print();
}
class PersonPrinterV1
{
void Print() { ... }
}
public partial class Person
{
[BeaKona.AutoInterface(typeof(IPrintable))]
private readonly PersonPrinterV1 aspect1 = new PersonPrinterV1();
}
Auto-generated accompanying source:
partial class Person : IPrintable
{
void IPrintable.Print() => this.aspect1.Print();
}
<br />
Generate code from a template
Manually written source:
interface IPrintable
{
void Print();
}
public partial class Person : IPrintable
{
// add file mytemplate.scriban in your VS project
// and set it's build action to: 'C# analyzer additional file'
[BeaKona.AutoInterface(TemplateFileName = "mytemplate.scriban")]
private readonly IPrintable? aspect1 = null;
}
Auto-generated accompanying source:
partial class Person
{
..generated from file..
}
<br />
Partial template
Partial template can be defined inline (from string) or from file.
Manually written source:
interface IPrintable
{
int Length { get; }
int Count { get; }
void Print1();
void Print2();
}
public partial class Person : IPrintable
{
private void LogDebug(string name) { }
[BeaKona.AutoInterface]
[BeaKona.AutoInterfaceTemplate(BeaKona.AutoInterfaceTargets.PropertyGetter,
Filter = "Length", Language = "scriban", Body = "return 1;")]
[BeaKona.AutoInterfaceTemplate(BeaKona.AutoInterfaceTargets.Method,
Filter = "Print(\\d)?", Body="LogDebug(nameof({{interface}}.{{name}})); {{expression}};")]
private readonly IPrintable? aspect1 = new PrinterV1();
}
Auto-generated accompanying source:
partial class Person
{
int IPrintable.Length
{
return 1;
}
int IPrintable.Count => this.aspect1!.Count;
void IPrintable.Print1()
{
LogDebug(nameof(IPrintable.Print1));
this.aspect1!.Print1();
}
void IPrintable.Print2()
{
LogDebug(nameof(IPrintable.Print2));
this.aspect1!.Print2();
}
}
<br />
Other examples can be found in wiki.
<br />
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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 Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.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 |
|---|---|---|
| 1.0.46 | 227 | 2/16/2026 |
| 1.0.45.2 | 101 | 2/15/2026 |
| 1.0.44 | 3,150 | 7/13/2025 |
| 1.0.43-pre | 1,804 | 5/12/2024 |
| 1.0.42 | 39,159 | 4/9/2024 |
| 1.0.41 | 399 | 3/19/2024 |
| 1.0.40-pre | 152 | 3/19/2024 |
| 1.0.39-pre | 166 | 3/16/2024 |
| 1.0.38-pre | 151 | 3/15/2024 |
| 1.0.37-pre | 149 | 3/14/2024 |
| 1.0.36-pre | 162 | 3/14/2024 |
| 1.0.35-pre | 424 | 12/7/2023 |
| 1.0.34-pre | 208 | 12/3/2023 |
| 1.0.32-pre | 175 | 12/1/2023 |
| 1.0.31-pre | 157 | 11/30/2023 |
| 1.0.30-pre | 185 | 11/29/2023 |
| 1.0.29 | 10,168 | 6/16/2022 |
| 1.0.28 | 619 | 5/16/2022 |
| 1.0.27 | 579 | 5/16/2022 |
| 1.0.26 | 620 | 4/27/2022 |