SkyWebFramework.DependencyInjection
1.0.0
dotnet add package SkyWebFramework.DependencyInjection --version 1.0.0
NuGet\Install-Package SkyWebFramework.DependencyInjection -Version 1.0.0
<PackageReference Include="SkyWebFramework.DependencyInjection" Version="1.0.0" />
<PackageVersion Include="SkyWebFramework.DependencyInjection" Version="1.0.0" />
<PackageReference Include="SkyWebFramework.DependencyInjection" />
paket add SkyWebFramework.DependencyInjection --version 1.0.0
#r "nuget: SkyWebFramework.DependencyInjection, 1.0.0"
#:package SkyWebFramework.DependencyInjection@1.0.0
#addin nuget:?package=SkyWebFramework.DependencyInjection&version=1.0.0
#tool nuget:?package=SkyWebFramework.DependencyInjection&version=1.0.0
SkyWebFramework.DependencyInjection
SkyWebFramework.DependencyInjection (EasyDI) is an enterprise-grade, high-performance convention and attribute-driven Dependency Injection framework for .NET 8 and .NET 9.
It eliminates repetitive builder.Services.AddScoped<...>() boilerplate code by automatically scanning assemblies, resolving conventions, supporting modular composition, applying decorators/interceptors, and detecting captive/circular dependencies at startup.
🔗 Repository & Links
- GitHub Repository: Skyrunner-Dev-ops/SkyWebFramework.DependencyInjection
- NuGet Package: SkyWebFramework.DependencyInjection on NuGet.org
🌟 Key Features
- ⚡ Zero-Boilerplate Assembly Scanning: Automatically discovers interfaces and implementations by naming conventions.
- 🏷️ Attribute-Driven Lifetime Management: Decorate classes with
[Scoped],[Transient],[Singleton], or[EasyService]. - 🔑 Keyed Services (.NET 8/9): First-class support for
[KeyedService("key")]with automatic interface inference. - 🧩 Modular DI Architecture: Organize registrations cleanly into decoupled modules (
IEasyServiceModule) and profiles (IEasyServiceProfile) with priority ordering. - 🛡️ Diagnostic & Safety Engine: Built-in detection for Captive Dependencies (e.g. Scoped service inside Singleton) and Circular References.
- 🎨 Decorator & Interceptor Patterns: Wrap services programmatically (
services.Decorate<T, TDecorator>()) or via attributes ([Decorator(typeof(ITarget))]). - ⏳ Lazy Resolution (
Lazy<T>): Defer instantiation of heavy services until.Valueis accessed. - ⚙️ Flexible Configuration (
EasyDiOptions): Custom type filters, namespace whitelist/blacklist, duplicate registration behaviors (Skip,Replace,Throw).
📦 Installation
Install via NuGet Package Manager:
dotnet add package SkyWebFramework.DependencyInjection
Or via Package Manager Console:
Install-Package SkyWebFramework.DependencyInjection
🛠️ Clone & Build Locally
To clone and build the source code locally:
git clone https://github.com/Skyrunner-Dev-ops/SkyWebFramework.DependencyInjection.git
cd SkyWebFramework.DependencyInjection
dotnet build -c Release
🚀 Quick Start
In your ASP.NET Core Program.cs:
using SkyWebFramework.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
// 1. One-line auto-registration for your entire assembly!
builder.Services.AddEasyServices();
// 2. (Optional) Auto-discover and run all IEasyServiceModule & IEasyServiceProfile instances
builder.Services.AddEasyServiceModules(Assembly.GetExecutingAssembly());
// 3. (Optional) Run container safety diagnostics at startup
builder.Services.DetectCaptiveDependencies(throwOnError: true);
builder.Services.ValidateEasyServices();
var app = builder.Build();
app.MapControllers();
app.Run();
💡 Usage Examples
1. Attribute-Driven Registration
Simply decorate your classes to define their lifetime:
using SkyWebFramework.DependencyInjection;
public interface IOrderService { void CreateOrder(); }
[Scoped]
public class OrderService : IOrderService
{
public void CreateOrder() { /* Implementation */ }
}
[Singleton]
public class CacheService : ICacheService { }
[Transient]
public class PaymentGateway : IPaymentGateway { }
2. Convention-Based Scanning
Classes ending with Service, Repository, or Manager are automatically matched to I<ClassName> without requiring attributes!
// Automatically registered as Scoped under ICustomerRepository
public class CustomerRepository : ICustomerRepository { }
3. Keyed Services (.NET 8/9)
[KeyedService("email")]
public class EmailNotificationService : INotificationService { }
[KeyedService("sms")]
public class SmsNotificationService : INotificationService { }
// Consumer injection
public class NotificationController(
[FromKeyedServices("email")] INotificationService emailService,
[FromKeyedServices("sms")] INotificationService smsService)
{
// ...
}
4. Modular Architecture (IEasyServiceModule)
Cleanly decouple registration logic across distinct feature modules:
[ServiceModule("BillingModule", Priority = 1)]
public class BillingModule : IEasyServiceModule
{
public void RegisterServices(IServiceCollection services)
{
services.AddScoped<IBillingService, BillingService>();
}
}
// Auto-register all modules in priority order
services.AddEasyServiceModules(Assembly.GetExecutingAssembly());
5. Decorators & Interceptors
// Programmatically decorate existing service registration
services.Decorate<IOrderService, LoggingOrderDecorator>();
// Attribute-driven decorator
[Decorator(typeof(ICalculatorService))]
public class AuditCalculatorDecorator : ICalculatorService
{
private readonly ICalculatorService _inner;
public AuditCalculatorDecorator(ICalculatorService inner) => _inner = inner;
public int Add(int a, int b) => _inner.Add(a, b);
}
// Interceptor callback
services.InterceptService<IOrderService>((instance, provider) =>
{
Console.WriteLine("Invoking OrderService");
return instance;
});
6. Lazy Resolution (Lazy<T>)
// Enable Lazy<T> for all registered services
services.EnableLazyResolution();
// Service is NOT instantiated until .Value is accessed
public class ReportController(Lazy<IHeavyReportGenerator> lazyReportGenerator)
{
public void Generate() => lazyReportGenerator.Value.Build();
}
7. Diagnostics & Container Summary
// Print a registration report to the console at startup
services.PrintEasyServiceSummary();
// Export full container state as formatted JSON
string jsonReport = services.ExportRegistrationsAsJson();
🤝 Contributing
Contributions are welcome! Please feel free to submit issues or pull requests on GitHub.
- Fork the Repository:
https://github.com/Skyrunner-Dev-ops/SkyWebFramework.DependencyInjection - Create your Feature Branch:
git checkout -b feature/AmazingFeature - Commit your Changes:
git commit -m 'Add some AmazingFeature' - Push to the Branch:
git push origin feature/AmazingFeature - Open a Pull Request
📄 License
This project is licensed under the MIT License.
Copyright (c) 2026 Surya Pratap Singh - SkyWebFramework
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
-
net9.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.0)
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.0 | 97 | 8/25/2026 |