IoCTools.Generator
1.1.0
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
<PackageReference Include="IoCTools.Generator" Version="1.1.0" />
<PackageVersion Include="IoCTools.Generator" Version="1.1.0" />
<PackageReference Include="IoCTools.Generator" />
paket add IoCTools.Generator --version 1.1.0
#r "nuget: IoCTools.Generator, 1.1.0"
#:package IoCTools.Generator@1.1.0
#addin nuget:?package=IoCTools.Generator&version=1.1.0
#tool nuget:?package=IoCTools.Generator&version=1.1.0
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.
Quick Start
- Install
<PackageReference Include="IoCTools.Abstractions" Version="*" />
<PackageReference Include="IoCTools.Generator" Version="*" PrivateAssets="all" />
- 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;
}
- 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
- Getting Started: docs/getting-started.md
- Attributes & Usage: docs/attributes.md
- Lifetime Management: docs/lifetime-management.md
- Configuration Injection: docs/configuration-injection.md
- Conditional Services: docs/conditional-services.md
- Background Services: docs/background-services.md
- Interface Registration: docs/multi-interface-registration.md
- Generics: docs/generics.md
- Inheritance: docs/inheritance.md
- Diagnostics: docs/diagnostics.md
- Generator Style Options: docs/generator-style-options.md
- Recipes: docs/recipes.md
- FAQ: docs/faq.md
Sample
Browse IoCTools.Sample for end-to-end scenarios, including advanced patterns and background services.
License
MIT — see LICENSE.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.5.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.5.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.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 |
v1.1.0: Adds redundant registration diagnostics (IOC032-IOC038), null-safe generator test infrastructure, Inject-vs-DependsOn guidance, and refreshed documentation.