CastelloBranco.ServiceRegistrationGenerator 1.0.70

There is a newer version of this package available.
See the version list below for details.
dotnet add package CastelloBranco.ServiceRegistrationGenerator --version 1.0.70                
NuGet\Install-Package CastelloBranco.ServiceRegistrationGenerator -Version 1.0.70                
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="CastelloBranco.ServiceRegistrationGenerator" Version="1.0.70" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CastelloBranco.ServiceRegistrationGenerator --version 1.0.70                
#r "nuget: CastelloBranco.ServiceRegistrationGenerator, 1.0.70"                
#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.
// Install CastelloBranco.ServiceRegistrationGenerator as a Cake Addin
#addin nuget:?package=CastelloBranco.ServiceRegistrationGenerator&version=1.0.70

// Install CastelloBranco.ServiceRegistrationGenerator as a Cake Tool
#tool nuget:?package=CastelloBranco.ServiceRegistrationGenerator&version=1.0.70                

ServiceRegistrationGenerator ServiceRegistrationGenerator is a source generator for .NET projects that automatically registers services into the dependency injection container based on custom attributes. It simplifies the process of setting up DI by eliminating manual service registration.

Table of Contents Installation Usage Attributes Example License Contributing Support Installation You can install ServiceRegistrationGenerator via NuGet:

bash Copiar código dotnet add package ServiceRegistrationGenerator Alternatively, you can find it on the NuGet website.

Usage The ServiceRegistrationGenerator automatically registers services annotated with specific attributes ([RegisterAsSingleton], [RegisterAsTransient], etc.) into the DI container.

Add Attributes: Add custom attributes to your services to specify their DI lifetime.

Build the Project: The generator runs during compilation, generating a helper file that registers each annotated service.

Supported Attributes Attribute Lifetime Description [RegisterAsSingleton] Singleton Registers the service as a singleton. [RegisterAsTransient] Transient Registers the service as a transient instance.

Generated Code The generator produces a helper file, AppServicesHelper.g.cs, which includes a method to register all services in the DI container. This file is automatically updated whenever new attributes are added or modified.

Example

  1. Define Services and Use Attributes In your project, define interfaces and classes and use RegisterAsSingleton, RegisterAsTransient, or RegisterAsScoped attributes as needed.
Copiar código
using ServiceRegistrationGenerator;

[RegisterAsSingleton]
public interface IMySingletonService { }

public class MySingletonService : IMySingletonService { }

[RegisterAsTransient]
public interface IMyTransientService { }

public class MyTransientService : IMyTransientService { }
  1. Use the Generated Helper The generator will create a helper file with a RegisterServices method, which you can call during application startup:
public class Program
{
    public static void Main(string[] args)
    {
        var services = new ServiceCollection();
        AppServicesHelper.RegisterServices(services);
    }
}

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

Contributing Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.

Support For support or questions, please open an issue on the GitHub repository.

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. 
.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.0.80 98 11/13/2024 1.0.80 is deprecated because it is no longer maintained and has critical bugs.
1.0.71 74 11/13/2024
1.0.70 76 11/13/2024
1.0.60 82 11/12/2024
1.0.50 76 11/12/2024
1.0.35 75 11/12/2024
1.0.30 78 11/12/2024
1.0.25 72 11/12/2024
1.0.22 81 11/12/2024
1.0.21 78 11/12/2024
1.0.0.21 73 11/12/2024
1.0.0.20 91 11/11/2024