IoCTools.Abstractions 1.0.0-alpha

This is a prerelease version of IoCTools.Abstractions.
There is a newer version of this package available.
See the version list below for details.
dotnet add package IoCTools.Abstractions --version 1.0.0-alpha
                    
NuGet\Install-Package IoCTools.Abstractions -Version 1.0.0-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IoCTools.Abstractions" Version="1.0.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IoCTools.Abstractions" Version="1.0.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="IoCTools.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add IoCTools.Abstractions --version 1.0.0-alpha
                    
#r "nuget: IoCTools.Abstractions, 1.0.0-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package IoCTools.Abstractions@1.0.0-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=IoCTools.Abstractions&version=1.0.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=IoCTools.Abstractions&version=1.0.0-alpha&prerelease
                    
Install as a Cake Tool

IoCTools

Eliminate dependency injection boilerplate and scattered service registrations. IoCTools is a .NET source generator that lets services declare their own dependencies and lifetime directly in their implementation, turning verbose DI configuration into simple, maintainable code.

// Before: Verbose constructor + separate registration
public class OrderService(IPaymentService payment, IEmailService email, 
    ILogger<OrderService> logger) : IOrderService 
{
    private readonly IPaymentService _payment = payment;
    private readonly IEmailService _email = email;
    private readonly ILogger<OrderService> _logger = logger;
}

// Program.cs
builder.Services.AddScoped<IOrderService, OrderService>();
builder.Services.AddScoped<IPaymentService, PaymentService>();
// ... many more lines

// After: Clean service with co-located registration
[Service] 
public partial class OrderService : IOrderService
{
    [Inject] private readonly IPaymentService _payment;
    [Inject] private readonly IEmailService _email;
    [Inject] private readonly ILogger<OrderService> _logger;
}

// Program.cs
builder.Services.AddIoCTools[ProjectName]RegisteredServices(); // All services discovered automatically

NuGet NuGet Status Sample Coverage


🚀 Quick Start

1. Install the packages:

<PackageReference Include="IoCTools.Abstractions" Version="*" />
<PackageReference Include="IoCTools.Generator" Version="*" PrivateAssets="all" />

2. Mark your service with [Service] and use [Inject] for dependencies:

[Service]
public partial class EmailService : IEmailService
{
    [Inject] private readonly ILogger<EmailService> _logger;
    
    public async Task SendEmailAsync(string to, string subject, string body)
    {
        _logger.LogInformation("Sending email to {To}", to);
        // Implementation here
    }
}

3. Register all services automatically:

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIoCTools[ProjectName]RegisteredServices();
var app = builder.Build();

That's it! 🎉 Your service is now automatically registered with the correct lifetime and all dependencies are injected.

🔧 Optional: Configure Diagnostics

Add these MSBuild properties to your project file to customize diagnostic behavior:

<PropertyGroup>
  
  <IoCToolsNoImplementationSeverity>Error</IoCToolsNoImplementationSeverity>
  
  
  <IoCToolsUnregisteredSeverity>Info</IoCToolsUnregisteredSeverity>
  
  
  <IoCToolsDisableDiagnostics>true</IoCToolsDisableDiagnostics>
</PropertyGroup>

Severity Options: Error, Warning, Info, Hidden


✨ Key Benefits

🔥 Co-located Registration

Service registration happens right where the service is defined, eliminating the hunt through Program.cs

Zero Boilerplate

No more verbose constructors, parameter assignments, or manual registration calls

🛡️ Compile-Time Safety

Comprehensive diagnostics catch missing implementations, circular dependencies, and lifetime mismatches at build time

🎯 IntelliSense Friendly

Full IDE support with code completion, refactoring, and go-to-definition for generated code

📦 Comprehensive Testing

Extensive sample application with 59 comprehensive examples covering all features and edge cases


🎯 Feature Highlights

Core Features:

Advanced Features:

Developer Experience:


📚 Documentation

Getting Started

Core Features

Advanced Features

Developer Tools

Integration Guides


🔥 Real-World Example

Here's a complete e-commerce service showcasing multiple IoCTools features:

[Service(Lifetime.Scoped)]
[ConditionalService(Environment = "Production")]
[RegisterAsAll(RegistrationMode.All, InstanceSharing.Shared)]
public partial class OrderService : IOrderService, IOrderValidator
{
    [Inject] private readonly IPaymentService _paymentService;
    [Inject] private readonly IEmailService _emailService;
    [Inject] private readonly ILogger<OrderService> _logger;
    
    [InjectConfiguration("OrderProcessing:MaxRetries")] 
    private readonly int _maxRetries;
    
    [InjectConfiguration] 
    private readonly ShippingOptions _shippingOptions;

    public async Task<OrderResult> ProcessOrderAsync(Order order)
    {
        _logger.LogInformation("Processing order {OrderId}", order.Id);
        
        // Use injected configuration
        for (int i = 0; i < _maxRetries; i++)
        {
            var paymentResult = await _paymentService.ProcessPaymentAsync(order.Payment);
            if (paymentResult.Success) break;
        }
        
        // Generated constructor handles all dependencies automatically:
        // public OrderService(IPaymentService paymentService, IEmailService emailService, 
        //     ILogger<OrderService> logger, IConfiguration configuration)
    }
}

Generated registration code:

// Only registers in Production environment
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Production")
{
    services.AddScoped<IOrderService>(provider => provider.GetRequiredService<OrderService>());
    services.AddScoped<IOrderValidator>(provider => provider.GetRequiredService<OrderService>());
    services.AddScoped<OrderService>();
}

📋 Comprehensive Sample Application

The IoCTools.Sample project provides 59 comprehensive examples demonstrating every feature:

Run the sample application to see all features in action:

dotnet run --project IoCTools.Sample

🛠️ Development Status

  • ✅ Core Features: Stable and feature-complete with comprehensive sample coverage
  • ⚠️ Advanced Features: Stable with extensive examples, some edge cases documented as architectural limits
  • 🚀 v1.0.0-alpha: Feature-complete alpha release with production-ready architecture and comprehensive validation
  • 🏗️ Architectural Limits: Intentional design boundaries with documented workarounds

Sample Coverage: 59 comprehensive examples covering all features, diagnostics, and integration patterns with 100% test success rate

Note: Some advanced scenarios (complex access modifiers, extreme generic constraints) are intentional architectural limits. See Architectural Limits for details and workarounds.


🤝 Contributing

We welcome contributions! See our Contributing Guide for details.

Found a bug? Open an issue Have a feature idea? Start a discussion


📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🌟 Why Choose IoCTools?

For Teams: Eliminates DI configuration drift and makes service dependencies explicit and maintainable

For Performance: Zero runtime overhead - all resolution happens at compile time with build-time validation

For Developers: IntelliSense-friendly generated code that integrates seamlessly with existing .NET patterns

For Architecture: Supports sophisticated patterns like conditional services, multi-interface registration, and configuration injection while maintaining simplicity


Built with ❤️ for the .NET community

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
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
1.9.1 88 5/23/2026
1.8.0 1,192 5/12/2026
1.7.3 1,545 5/6/2026
1.7.2 88 5/6/2026
1.7.1 94 5/6/2026
1.6.1 98 4/29/2026
1.6.0 91 4/29/2026
1.5.1 143 4/12/2026
1.4.0 211 3/21/2026
1.3.0 118 1/24/2026
1.2.0 403 11/18/2025
1.1.0 294 11/12/2025
1.0.0 198 9/10/2025
1.0.0-alpha 243 8/28/2025
0.4.1 177 11/30/2024
0.4.0 150 11/30/2024
0.3.0 213 3/18/2024
0.2.6 186 2/6/2024
0.2.5 308 2/6/2024
0.2.4 183 2/6/2024
Loading failed

v1.0.0-alpha: Feature-complete alpha release with comprehensive diagnostic system, full inheritance support, and production-ready architecture. Includes 100% test success rate and extensive sample application with 59 comprehensive examples.