MicrosoftDI.AddXRefactoring 0.4.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package MicrosoftDI.AddXRefactoring --version 0.4.1
NuGet\Install-Package MicrosoftDI.AddXRefactoring -Version 0.4.1
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="MicrosoftDI.AddXRefactoring" Version="0.4.1">
  <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.4.1
#r "nuget: MicrosoftDI.AddXRefactoring, 0.4.1"
#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 MicrosoftDI.AddXRefactoring as a Cake Addin
#addin nuget:?package=MicrosoftDI.AddXRefactoring&version=0.4.1

// Install MicrosoftDI.AddXRefactoring as a Cake Tool
#tool nuget:?package=MicrosoftDI.AddXRefactoring&version=0.4.1

Microsoft DI AddX Refactoring Provider

This project provides 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

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.
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 1,364 2/22/2022
1.0.0 705 2/19/2022
0.6.2 453 2/19/2022
0.6.1 468 2/19/2022
0.6.0 425 2/15/2022
0.5.0 682 2/5/2022
0.4.1 708 2/4/2022
0.4.0 756 1/31/2022
0.3.0 670 1/30/2022
0.2.0 650 1/29/2022
0.1.2 690 1/27/2022
0.1.1 707 1/17/2022
0.1.0 677 1/16/2022