SourceGeneratorPower.Services.SourceGenerator
1.0.0-preview2
This is a prerelease version of SourceGeneratorPower.Services.SourceGenerator.
dotnet add package SourceGeneratorPower.Services.SourceGenerator --version 1.0.0-preview2
NuGet\Install-Package SourceGeneratorPower.Services.SourceGenerator -Version 1.0.0-preview2
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="SourceGeneratorPower.Services.SourceGenerator" Version="1.0.0-preview2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SourceGeneratorPower.Services.SourceGenerator --version 1.0.0-preview2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SourceGeneratorPower.Services.SourceGenerator, 1.0.0-preview2"
#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 SourceGeneratorPower.Services.SourceGenerator as a Cake Addin #addin nuget:?package=SourceGeneratorPower.Services.SourceGenerator&version=1.0.0-preview2&prerelease // Install SourceGeneratorPower.Services.SourceGenerator as a Cake Tool #tool nuget:?package=SourceGeneratorPower.Services.SourceGenerator&version=1.0.0-preview2&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SourceGeneratorPower.Services
SourceGeneratorPower.Services is used C# roslyn's Source Generator feature to auto inject services which marked by TransientServiceAttribute, ScopedServiceAttribute or SingletonServiceAttribute. It is convenient to develop, almost no loss of performance.
Installation
dotnet add package SourceGeneratorPower.Services.Abstractions
dotnet add package SourceGeneratorPower.Services.SourceGenerator
Design
Marked interface or class as specified lifetime service
On Interface:
- Pure Attribute: Scan the interface and all its implementation classes and generate source codes added to the container with the specified lifetime.
- Parameters Attribute: Use the class of the parameters as the implementation class to generate source codes added to the container
On Class:
- Pure Attribute: Add the class as an interface and implementation class to generate source codes into the container.
- Parameters Attribute: Use the interface of the parameters as and self as implement class to generate source codes added to the container.
Usages
- Marked Interface or Class with specified lifetime ServiceAttribute
[SingletonService]
public interface ISingletonGuidGenerator
{
string Generate();
}
Main project use IServiceCollection extension method AddAutoInjectServices
// .Net 6
builder.Services.AddAutoInjectServices();
// .Net 5 StartUp.cs
service.AddAutoInjectServices();
Then build solution
There are no supported framework assets in this 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.0-preview2 | 111 | 5/7/2023 |
1.0.0-preview1 | 102 | 2/3/2023 |