Injectlynx 1.0.1
dotnet add package Injectlynx --version 1.0.1
NuGet\Install-Package Injectlynx -Version 1.0.1
<PackageReference Include="Injectlynx" Version="1.0.1" />
<PackageVersion Include="Injectlynx" Version="1.0.1" />
<PackageReference Include="Injectlynx" />
paket add Injectlynx --version 1.0.1
#r "nuget: Injectlynx, 1.0.1"
#:package Injectlynx@1.0.1
#addin nuget:?package=Injectlynx&version=1.0.1
#tool nuget:?package=Injectlynx&version=1.0.1
Injectlynx
Injectlynx is an attribute-free, compile-time dependency injection toolkit for .NET 8, .NET 9, and .NET 10. Developers configure services with a strongly typed C# convention DSL, and a Roslyn source generator emits Microsoft.Extensions.DependencyInjection registrations during build.
No service attributes, runtime reflection scanning, or custom container are required.
Contributing · MIT License · Security
Install
dotnet add package Injectlynx
NuGet package: https://www.nuget.org/packages/Injectlynx
During source-tree development, samples reference the local src/Injectlynx project and generator assemblies directly.
Supported Targets
Injectlynx ships public DSL assemblies for netstandard2.0, net8.0, net9.0, and net10.0. The Roslyn generator is packaged as an analyzer, and the samples/validation suite verify .NET 8, .NET 9, and .NET 10 application projects.
Quick Start
Create a module-level convention class:
using Injectlynx;
public static class ApplicationServiceConventions
{
public static void Configure(IServiceConventionBuilder services)
{
services
.FromNamespace("Shop.Application.Services")
.WhereNameEndsWith("Service")
.AsMatchingInterface()
.WithScopedLifetime();
}
}
Use the generated extension method:
builder.Services.AddInjectlynxServices();
By default, Injectlynx generates AddInjectlynxServices() for every project.
Use GeneratedMethod("AddInfrastructureServices") or another project-specific name when multiple libraries expose generated registrations to the same app, or when your team wants a more explicit startup call.
If you also use GeneratedNamespace("MyApp.DependencyInjection"), add using MyApp.DependencyInjection; in Program.cs. The method is generated at build time; developers do not write it manually.
For OrderService : IOrderService, Injectlynx generates a registration equivalent to:
services.AddScoped<IOrderService, OrderService>();
Supported DSL Scenarios
- Convention registration by namespace, class prefix/suffix, interface prefix/suffix, and open generic assignability.
- Registration strategies: matching interface, all implemented interfaces, self, or matching interface plus self.
- Singleton, scoped, and transient lifetimes.
- Exclusions with
ExcludeNamespace(...)andExcludeType<T>(). - Explicit and keyed registrations with
Register<TService, TImplementation>()andWithKey(...). - External/framework-provided service declarations for dependency diagnostics.
- Decorators with
Decorate<TService, TDecorator>(). - Architecture guardrails with
ForbidDependency(). - Diagnostic severity overrides with
Diagnostic("INJ401").AsWarning(). - Custom generated method and namespace names.
- Opt-in property and method injection for cases where constructor injection is not practical.
Registration Examples
Concrete class only:
services
.FromNamespace("Shop.Infrastructure.Clients")
.WhereNameEndsWith("Client")
.AsSelf()
.WithSingletonLifetime();
All implemented interfaces:
services
.FromNamespace("Shop.Application.Processors")
.WhereNameEndsWith("Processor")
.AsImplementedInterfaces()
.WithScopedLifetime();
Only interfaces with a naming pattern:
services
.FromNamespace("Shop.Application.Stores")
.WhereInterfaceNameStartsWith("IRead")
.AsImplementedInterfaces()
.WithTransientLifetime();
One specific interface from a multi-interface implementation:
services
.Register<IWriteOrderStore, OrderStore>()
.WithScopedLifetime();
Development Investigation
To inspect generated registrations during development:
dotnet build -p:InjectlynxDevelopmentReport=true
For normal console-visible output, temporarily use:
dotnet build -p:InjectlynxDevelopmentReport=warning
This emits INJ900 diagnostics such as:
OrderService -> IOrderService (Scoped)
Keep this disabled in CI and production builds.
Samples
samples/MinimalApi: broad DSL coverage, including member injection and open generic handlers.samples/WebApi: controller-based app with explicit/keyed registrations, decorators, external services, and architecture rules.samples/WorkerService: hosted background worker registration.samples/NativeAot: Native AOT-focused sample without runtime scanning.
Build a sample:
dotnet build samples/WebApi/WebApi.csproj --no-restore
Future Tooling Roadmap
- Keep
src/Injectlynx.Analyzersreserved for diagnostics that become too large to maintain inside the source generator. - Keep
src/Injectlynx.CodeFixesreserved until analyzer rules are stable and IDE quick fixes are worth maintaining. - Keep
src/Injectlynx.Clireserved for graph or inspection tooling if users ask for tooling outside the IDE.
Validation
dotnet build Injectlynx.slnx
dotnet test Injectlynx.slnx --no-build
dotnet pack src/Injectlynx/Injectlynx.csproj -c Debug --no-build -o artifacts/packages
bash eng/release/verify-packages.sh
bash eng/validation/validate-local-package.sh
See docs/configuration/configuration.md for the full DSL guide.
| 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 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 is compatible. 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.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.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.0.1 | 42 | 8/1/2026 |
Supports netstandard2.0, .NET 8, .NET 9, and .NET 10. The source generator is packaged as an analyzer.