Marionette.Orange 0.0.6

dotnet add package Marionette.Orange --version 0.0.6
                    
NuGet\Install-Package Marionette.Orange -Version 0.0.6
                    
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="Marionette.Orange" Version="0.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Marionette.Orange" Version="0.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Marionette.Orange" />
                    
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 Marionette.Orange --version 0.0.6
                    
#r "nuget: Marionette.Orange, 0.0.6"
                    
#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 Marionette.Orange@0.0.6
                    
#: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=Marionette.Orange&version=0.0.6
                    
Install as a Cake Addin
#tool nuget:?package=Marionette.Orange&version=0.0.6
                    
Install as a Cake Tool

Marionette.Orange

Marionette.Orange 是一个轻量级的基于属性的依赖注入辅助库,配套一个增量 Roslyn 源生成器,用于在构建时自动生成 IServiceCollection 的注册扩展方法。


特性

  • 通过属性声明依赖注入语义([Injection][Injectable][InjectContext]
  • 增量 Roslyn 源生成器:在编译期间生成类型安全的 IServiceCollection 扩展(例如 AddInjections
  • 支持生命周期:Singleton、Transient、Scoped(以及作为 HostedService 的注册)
  • 支持按 Key 的多实现注册
  • 生成器诊断:在分析/生成阶段产生日志和诊断信息,方便排查
  • 带有示例项目:src/Marionette.Orange.SourceGenerators.Sample

快速开始

  1. 安装nuget包
dotnet add package Marionette.Orange
  1. 在期望被注入的接口上使用 [Injectable] 标记作为注入契约。
[Injectable]
public interface IFoo;
  1. 在实现类上使用 [Injection] 指定所实现的接口与生命周期;可选地指定 Key 以及接口类型
[Injection(InjectAs.Singleton)]
public class Foo1 : IFoo;

[Injection(InjectAs.Scope, typeof(IOther), Key="Foo2")] 
public class Foo2 : IOther;
  1. 在某个对于IServiceCollection的拓展方法上使用 [InjectContext]

note:该方法和拓展类必须是分布方法

public static partial class SeviceCollectionExtension 
{
    [InjectContext] 
    public static partial IServiceCollection AddMarionetteOrangeService(this IServiceCollection);
}
  1. 在构建ServiceCollection的地方调用生成的方法(比如 Program.cs)
services.
    ...
    .AddMarionetteOrangeService()
    ...

更多详细示例请查看:src/Marionette.Orange.SourceGenerators.Sample

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.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
0.0.6 80 9/15/2026
0.0.5 79 9/10/2026
0.0.4 104 9/7/2026

Initial package metadata update.