Automatic interface delegation to adopted members using source generators.
- C# 98%
- Dockerfile 1%
- Shell 1%
TypeAdoption
TypeAdoption LogoAdopt the implementations of members in your class and embrace delegation, composition over inheritance, and mix-in style
coding in C# by adding the [Adopt] attribute to members or properties:
public partial class ConfiguredLogger<T>(ILogger<T> innerLogger)
{
[Adopt]
private readonly ILogger<T> _innerLogger = innerLogger;
public bool IsEnabled(LogLevel logLevel)
{
return logLevel > LogLevel.Debug;
}
// Other ILogger members are automatically delegated to _innerLogger in an automatically generated partial class.
}
Usage
Installation
Installation
Add it to your csproj:
<PackageReference Include="NameHillSoftware.TypeAdoption" Version="version" OutputItemType="Analyzer">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
More usage examples can be found in the project README.md.
Development
Credit
This project was originally started as a fork of Decorator Generator. All credit to Leopoldo Fu for their well-written library, it provided an excellent base for getting started!
License
This project is licensed under the Apache License Version 2.0 - see the LICENSE file for details.