MicrosoftDI.AddXRefactoring 0.5.0

There is a newer version of this package available.
See the version list below for details.
Install-Package MicrosoftDI.AddXRefactoring -Version 0.5.0
dotnet add package MicrosoftDI.AddXRefactoring --version 0.5.0
<PackageReference Include="MicrosoftDI.AddXRefactoring" Version="0.5.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.
paket add MicrosoftDI.AddXRefactoring --version 0.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MicrosoftDI.AddXRefactoring, 0.5.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MicrosoftDI.AddXRefactoring as a Cake Addin
#addin nuget:?package=MicrosoftDI.AddXRefactoring&version=0.5.0

// Install MicrosoftDI.AddXRefactoring as a Cake Tool
#tool nuget:?package=MicrosoftDI.AddXRefactoring&version=0.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Nuget

Microsoft DI AddX Refactoring Provider

This project provides Roslyn code refactoring, which automatically adds Add(Singleton|Scoped|Transient) from your new class declaration into nearest DI registration point. It could be default ConfigureServices in Startup.cs, or your custom extension method analogous to it.

Prerequisites

  1. You use Microsoft.Extensions.DependencyInjection to register services
  2. You use default ConfigureServices in Startup.cs and/or custom extension methods to register services with following signature:
public static class Module 
{
    public static IServiceCollection RegisterServices(this IServiceCollection services)
    {
        return services.AddSingleton<Foo>()
            ...
            ;
    }
}

Installation

It can be installed in any project through nuget package

Features

  • Code Actions with AddSingleton|AddScoped|AddTransient methods with appropriate type parameters will be inferred from your class declaration.
  • First base type in your class declaration will be used as a first type argument in extension method call.
  • Code action will add registration onto first line of nearest registration method with separate statement services.AddX<IFoo, Foo>();.
  • You can annotate method which follows convention, but you don't want to be considered as RegistrationMethod with [IgnoreRegistrationMethod] attribute.
  • You can annotate method which does not follow convention, but you want it to be considered as RegistrationMethod with [RegistrationMethod] attribute.
  • Add required using if it is not yet added
  • Code action will add registration into return services.AddX<Foo>().AddX<Bar>() invocation chain.
  • You can trigger refactoring on a specific item in your class' base list, and it will register method as such base.
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has 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 215 2/22/2022
1.0.0 296 2/19/2022
0.6.2 72 2/19/2022
0.6.1 74 2/19/2022
0.6.0 79 2/15/2022
0.5.0 86 2/5/2022
0.4.1 89 2/4/2022
0.4.0 92 1/31/2022
0.3.0 81 1/30/2022
0.2.0 81 1/29/2022
0.1.2 87 1/27/2022
0.1.1 90 1/17/2022
0.1.0 84 1/16/2022