Skip to content

feat: basic IoC implementation based on source generation#2370

Open
ruattd wants to merge 7 commits intodevfrom
feat/ioc
Open

feat: basic IoC implementation based on source generation#2370
ruattd wants to merge 7 commits intodevfrom
feat/ioc

Conversation

@ruattd
Copy link
Contributor

@ruattd ruattd commented Feb 6, 2026

Introduce a new inversion of control (IoC) programming and basic dependency injection based on lifecycle startup and source generation.

Simple usages

Provider:

[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property)]
[DependencyCollector<RpcFunction>("rpc-function", AttributeTargets.Method)]
[DependencyCollector<string>("rpc-property", AttributeTargets.Property)]
public sealed class RpcAttribute(string name) : Attribute;

[LifecycleService(LifecycleState.Loaded)]
[LifecycleScope("rpc", "RPC")]
public sealed partial class RpcService
{
    // existing code...
    [LifecycleDependencyInjection("rpc-property", AttributeTargets.Property)]
    private static void _LoadProperties(ImmutableList<(PropertyAccessor<string> prop, string name)> props)
    {
        // process logic...
    }
    [LifecycleDependencyInjection("rpc-function", AttributeTargets.Method)]
    private static void _LoadFunctions(ImmutableList<(RpcFunction func, string name)> funcs)
    {
        // process logic...
    }
    // existing code...
}

Dependency:

[Rpc("user")]
public static string Username { get; set; }

[Rpc("activate")]
public static RpcResponse Activate(string? argument, string? content, bool indent)
{
    // process logic...
}

@pcl-ce-automation pcl-ce-automation bot added 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 size: L PR 大小评估:大型 labels Feb 6, 2026
@pcl-ce-automation pcl-ce-automation bot added size: XL PR 大小评估:超大型 and removed size: L PR 大小评估:大型 labels Feb 9, 2026
@ruattd ruattd marked this pull request as ready for review February 9, 2026 08:37
@pcl-ce-automation pcl-ce-automation bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 and removed 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 labels Feb 9, 2026
@ruattd ruattd requested a review from a team February 9, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XL PR 大小评估:超大型 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant