Ling.AutoInject 1.0.0

Additional Details

Source generator compatibility issue: these versions require Roslyn 4.14 and fail with CS9057 on supported .NET 6/8 and older Visual Studio compiler hosts. Upgrade to Ling.AutoInject 1.4.1, which supports Roslyn 4.3+.

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

Ling.AutoInject

Ling.AutoInject provides attribute-driven registration helpers and integrates with a source generator to emit IServiceCollection extension methods that register services discovered via attributes at compile time.

Features

  • Attributes: SingletonService, ScopedService, TransientService for simple, declarative registration.
  • Optional service typing and keyed registration support.
  • Configurable generated method name, host class and namespace through an assembly-level AutoInjectConfig attribute.
  • Complementary analyzers to surface common mistakes and invalid configurations in the IDE.

Installation

via .NET CLI:

dotnet add package Ling.AutoInject

via Package Manager Console:

Install-Package Ling.AutoInject

Usage

  1. Decorate implementation types:

    using Ling.AutoInject;
    
    [SingletonService]
    public class MyService { }
    
    [ScopedService(typeof(IFoo))]
    public class MyService : IFoo { }
    
    [TransientService(ServiceKey = "k1")]
    public class MyService { }
    
  2. (Optional) Configure generator output naming:

    [assembly: Ling.AutoInject.AutoInjectConfig(
        MethodName = "AddCustomServices",
        ClassName = "ServiceExtensions",
        Namespace = "MyNamespace")]
    
  3. Call the generated extension in Program / Startup:

    services.Add[MyAssembly]Services();
    // or
    services.AddCustomServices();
    

Notes

  • If no service type is specified, the implementation type is registered as itself.
  • If a service type is specified, the generator registers the mapping from service interface to implementation.
  • Keyed registration requires the DI Abstractions package to support keyed APIs; analyzers warn when unsupported.

Planned features

  • Options binding: future work will add attribute-driven registration and configuration binding for options classes (IOptions<T>), including section binding.

Contributing

  • PRs and issues welcome. Include tests for analyzer/generator changes.

License

  • MIT License.
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Ling.AutoInject:

Package Downloads
Ling.AutoInject.Options

Options registration contracts for Ling.AutoInject.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.0 131 11/12/2026
1.5.0 132 11/11/2026
1.4.1 179 9/11/2026
1.4.0 336 9/11/2026 1.4.0 is deprecated.
1.3.0 148 9/5/2026 1.3.0 is deprecated.
1.2.0 152 9/4/2026 1.2.0 is deprecated.
1.1.0 386 3/26/2026 1.1.0 is deprecated.
1.0.0 347 11/14/2025 1.0.0 is deprecated.