LayeredCraft.DecoWeaver
1.0.1.14
dotnet add package LayeredCraft.DecoWeaver --version 1.0.1.14
NuGet\Install-Package LayeredCraft.DecoWeaver -Version 1.0.1.14
<PackageReference Include="LayeredCraft.DecoWeaver" Version="1.0.1.14" />
<PackageVersion Include="LayeredCraft.DecoWeaver" Version="1.0.1.14" />
<PackageReference Include="LayeredCraft.DecoWeaver" />
paket add LayeredCraft.DecoWeaver --version 1.0.1.14
#r "nuget: LayeredCraft.DecoWeaver, 1.0.1.14"
#:package LayeredCraft.DecoWeaver@1.0.1.14
#addin nuget:?package=LayeredCraft.DecoWeaver&version=1.0.1.14
#tool nuget:?package=LayeredCraft.DecoWeaver&version=1.0.1.14
DecoWeaver
Compile-time decorator registration for .NET dependency injection
DecoWeaver is a .NET incremental source generator that brings compile-time decorator registration to your dependency injection setup. Using C# 11+ interceptors, it automatically wraps your service implementations with decorators at build time—eliminating runtime reflection, assembly scanning, and manual factory wiring.
Why DecoWeaver?
- ⚡ Zero runtime overhead - No reflection or assembly scanning at startup
- 🎯 Type-safe - Catches configuration errors at compile time
- 🚀 Fast - Incremental generation with Roslyn
- 🔧 Simple - Class-level or assembly-level decorator attributes
- 🌐 Flexible - Apply decorators globally or per-implementation
- 📦 Clean - Generates readable, debuggable interceptor code
Migrating from
DecoWeaver? TheDecoWeaverNuGet package has been deprecated in favor ofLayeredCraft.DecoWeaver. Update your package reference and replaceusing DecoWeaver.Attributes;withusing LayeredCraft.DecoWeaver.Attributes;in your code.
Installation
Install the NuGet package:
dotnet add package LayeredCraft.DecoWeaver --prerelease
Ensure your project uses C# 11 or later:
<PropertyGroup>
<LangVersion>11</LangVersion>
</PropertyGroup>
Quick Start
1. Mark your implementation with the decorator to apply
using LayeredCraft.DecoWeaver.Attributes;
[DecoratedBy<LoggingRepository>]
public class UserRepository : IUserRepository
{
// Your implementation
}
2. Register your service normally
services.AddScoped<IUserRepository, UserRepository>();
3. That's it!
At compile time, DecoWeaver automatically generates interceptor code that wraps UserRepository with LoggingRepository. When you resolve IUserRepository, you'll get the decorated instance.
LoggingRepository
└─ UserRepository
For more examples including open generics, multiple decorators, and ordering, see the Quick Start Guide.
Key Features
- Assembly-Level Decorators: Apply decorators to all implementations from one place with
[assembly: DecorateService(...)] - Class-Level Decorators: Apply decorators to specific implementations with
[DecoratedBy<T>] - Keyed Service Support: Works with keyed service registrations like
AddKeyedScoped<T, Impl>(serviceKey) - Factory Delegate Support: Works with factory registrations like
AddScoped<T, Impl>(sp => new Impl(...)) - Instance Registration Support: Works with singleton instances like
AddSingleton<T>(instance) - Opt-Out Support: Exclude specific decorators with
[DoNotDecorate] - Multiple Decorators: Stack multiple decorators with explicit ordering
- Generic Type Decoration: Decorate generic types like
IRepository<T>with open generic decorators - Type-Safe: Compile-time validation catches errors early
- Zero Configuration: No runtime registration or setup needed
- Debuggable: Generated code is readable and inspectable
Learn more in the Core Concepts documentation.
Requirements
- C# 11+ (for interceptors support)
- .NET 8.0+ (for keyed services)
- .NET SDK 8.0.400+ (Visual Studio 2022 17.11+)
See the Requirements page for full details.
Documentation
📖 Full Documentation - Comprehensive guides and API reference
Key sections:
- Installation - Get started with DecoWeaver
- Quick Start - Your first decorator in 5 minutes
- Core Concepts - Understand how it works
- Usage Guide - Detailed usage patterns
- Examples - Real-world scenarios
Contributing
Contributions are welcome! See our Contributing Guide for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ⚡ by the LayeredCraft team
| 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.
See the full changelog at https://layeredcraft.github.io/decoweaver/changelog/
Report issues: https://github.com/layeredcraft/decoweaver/issues