IoCTools.Generator 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package IoCTools.Generator --version 1.1.0
                    
NuGet\Install-Package IoCTools.Generator -Version 1.1.0
                    
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.Generator" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IoCTools.Generator" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="IoCTools.Generator" />
                    
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.Generator --version 1.1.0
                    
#r "nuget: IoCTools.Generator, 1.1.0"
                    
#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.Generator@1.1.0
                    
#: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.Generator&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=IoCTools.Generator&version=1.1.0
                    
Install as a Cake Tool

IoCTools

IoCTools is a .NET source generator that lets services declare their own dependencies and lifetimes using small, focused attributes. It generates constructors and service registrations at build time — no runtime reflection, minimal boilerplate.

NuGet NuGet

Quick Start

  1. Install
<PackageReference Include="IoCTools.Abstractions" Version="*" />
<PackageReference Include="IoCTools.Generator" Version="*" PrivateAssets="all" />
  1. Annotate a service
[Scoped]
public partial class EmailService : IEmailService
{
    [Inject] private readonly ILogger<EmailService> _logger;
    public Task SendAsync(string to, string subject, string body)
        => Task.CompletedTask;
}
  1. Register generated services
var builder = WebApplication.CreateBuilder(args);
// The method name is derived from your assembly: Add<YourAssemblyName>RegisteredServices
builder.Services.AddYourAssemblyNameRegisteredServices(builder.Configuration);

That’s it: IoCTools generates the constructor and service registrations.

Core Features

  • Modern lifetimes: [Scoped], [Singleton], [Transient]
  • Constructor params (recommended): [DependsOn<T...>] — no fields created
  • Field injection (last resort): [Inject] only when you truly need a field or specific naming
  • Configuration injection: [InjectConfiguration] (values, sections, options)
  • Interface control: RegisterAs<T...>, RegisterAsAll, SkipRegistration
  • Conditional registration: [ConditionalService] by environment/config
  • Background services: auto-detect BackgroundService/IHostedService
  • Diagnostics: actionable build-time checks

Docs

Start here: docs/index.md

Sample

Browse IoCTools.Sample for end-to-end scenarios, including advanced patterns and background services.

License

MIT — see LICENSE.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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 97 5/23/2026
1.8.0 3,868 5/12/2026
1.7.3 1,578 5/6/2026
1.7.2 97 5/6/2026
1.7.1 91 5/6/2026
1.6.1 99 4/29/2026
1.6.0 99 4/29/2026
1.5.1 142 4/12/2026
1.4.0 213 3/21/2026
1.3.0 119 1/24/2026
1.2.0 408 11/18/2025
1.1.0 293 11/12/2025
1.0.0 199 9/10/2025
1.0.0-alpha 231 8/28/2025
0.4.1 160 11/30/2024
0.4.0 150 11/30/2024
0.3.0 226 3/18/2024
0.2.6 260 2/6/2024
0.2.5 262 2/6/2024
0.2.4 267 2/6/2024
Loading failed

v1.1.0: Adds redundant registration diagnostics (IOC032-IOC038), null-safe generator test infrastructure, Inject-vs-DependsOn guidance, and refreshed documentation.