Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ Architecture 负责统一生命周期编排,核心阶段包括:

### CQRS

命令与查询分离,支持同步与异步执行。当前版本内建自有 CQRS runtime、行为管道和 handler 自动注册;公开 API 里仍保留少量历史
`Mediator` 命名以兼容旧调用点,但这些别名已进入正式弃用周期:新代码应使用 `Cqrs` 命名入口,旧别名会继续兼容一段时间并计划在未来
major 版本中移除。
命令与查询分离,支持同步与异步执行。当前版本内建自有 CQRS runtime、行为管道和 handler 自动注册;历史 `Mediator`
兼容别名已从公开 API 移除,统一使用 `Cqrs` 命名入口。

### EventBus

Expand Down
15 changes: 0 additions & 15 deletions GFramework.Core.Abstractions/Architectures/IArchitecture.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.ComponentModel;
using System.Reflection;
using GFramework.Core.Abstractions.Lifecycle;
using GFramework.Core.Abstractions.Model;
Expand Down Expand Up @@ -82,20 +81,6 @@ public interface IArchitecture : IAsyncInitializable, IAsyncDestroyable, IInitia
void RegisterCqrsPipelineBehavior<TBehavior>()
where TBehavior : class;

/// <summary>
/// 注册 CQRS 请求管道行为。
/// 该成员保留旧名称以兼容历史调用点,内部行为与 <see cref="RegisterCqrsPipelineBehavior{TBehavior}" /> 一致。
/// 新代码不应继续依赖该别名;兼容层计划在未来的 major 版本中移除。
/// 既支持实现 <c>IPipelineBehavior&lt;,&gt;</c> 的开放泛型行为类型,
/// 也支持绑定到单一请求/响应对的封闭行为类型。
/// </summary>
/// <typeparam name="TBehavior">行为类型,必须是引用类型</typeparam>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete(
"Use RegisterCqrsPipelineBehavior<TBehavior>() instead. This compatibility alias will be removed in a future major version.")]
void RegisterMediatorBehavior<TBehavior>()
where TBehavior : class;

/// <summary>
/// 从指定程序集显式注册 CQRS 处理器。
/// 当处理器位于默认架构程序集之外的模块或扩展程序集中时,可在初始化阶段调用该入口接入对应程序集。
Expand Down
15 changes: 1 addition & 14 deletions GFramework.Core.Abstractions/Ioc/IIocContainer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel;
using System.Reflection;
using System.Reflection;
using GFramework.Core.Abstractions.Rule;
using GFramework.Core.Abstractions.Systems;

Expand Down Expand Up @@ -97,18 +96,6 @@ void RegisterScoped<TService, TImpl>()
void RegisterCqrsPipelineBehavior<TBehavior>()
where TBehavior : class;

/// <summary>
/// 注册 CQRS 请求管道行为。
/// 该成员保留旧名称以兼容历史调用点,内部行为与 <see cref="RegisterCqrsPipelineBehavior{TBehavior}" /> 一致。
/// 新代码不应继续依赖该别名;兼容层计划在未来的 major 版本中移除。
/// </summary>
/// <typeparam name="TBehavior">行为类型,必须是引用类型</typeparam>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete(
"Use RegisterCqrsPipelineBehavior<TBehavior>() instead. This compatibility alias will be removed in a future major version.")]
void RegisterMediatorBehavior<TBehavior>()
where TBehavior : class;

/// <summary>
/// 从指定程序集显式注册 CQRS 处理器。
/// 该入口适用于处理器不位于默认架构程序集中的场景,例如扩展包、模块程序集或拆分后的业务程序集。
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GFramework.SourceGenerators.Abstractions.Architectures;
namespace GFramework.Core.SourceGenerators.Abstractions.Architectures;

/// <summary>
/// 标记架构模块类型,Source Generator 会根据注册特性生成 <c>Install</c> 方法。
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GFramework.SourceGenerators.Abstractions.Architectures;
namespace GFramework.Core.SourceGenerators.Abstractions.Architectures;

/// <summary>
/// 声明架构模块需要自动注册的模型类型。
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GFramework.SourceGenerators.Abstractions.Architectures;
namespace GFramework.Core.SourceGenerators.Abstractions.Architectures;

/// <summary>
/// 声明架构模块需要自动注册的系统类型。
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GFramework.SourceGenerators.Abstractions.Architectures;
namespace GFramework.Core.SourceGenerators.Abstractions.Architectures;

/// <summary>
/// 声明架构模块需要自动注册的工具类型。
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GFramework.SourceGenerators.Abstractions.Bases;
namespace GFramework.Core.SourceGenerators.Abstractions.Bases;

/// <summary>
/// 标记类的优先级,自动生成 <c>GFramework.Core.Abstractions.Bases.IPrioritized</c> 接口实现。
Expand Down Expand Up @@ -32,4 +32,4 @@ public PriorityAttribute(int value)
/// 获取优先级值
/// </summary>
public int Value { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GFramework.SourceGenerators.Abstractions.Enums;
namespace GFramework.Core.SourceGenerators.Abstractions.Enums;

/// <summary>
/// 标注在 enum 上,Source Generator 会为该 enum 生成扩展方法。
Expand All @@ -15,4 +15,4 @@ public sealed class GenerateEnumExtensionsAttribute : Attribute
/// 是否生成一个 IsIn(params T[]) 方法以简化多值判断(默认 true)。
/// </summary>
public bool GenerateIsInMethod { get; set; } = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- 引入必要的命名空间 -->
<ItemGroup>
<Using Include="GFramework.SourceGenerators.Abstractions"/>
<Using Include="GFramework.Core.SourceGenerators.Abstractions"/>
</ItemGroup>
<ItemGroup>
<PackageReference Update="Meziantou.Analyzer" Version="3.0.46">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;
global using System.Threading.Tasks;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#nullable enable
namespace GFramework.SourceGenerators.Abstractions.Logging;
namespace GFramework.Core.SourceGenerators.Abstractions.Logging;

/// <summary>
/// 标注在类上,Source Generator 会为该类自动生成一个日志记录器字段。
Expand Down Expand Up @@ -35,4 +35,4 @@ public LogAttribute(string? name)

/// <summary>访问修饰符</summary>
public string AccessModifier { get; set; } = "private";
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace GFramework.SourceGenerators.Abstractions.Rule;
namespace GFramework.Core.SourceGenerators.Abstractions.Rule;

/// <summary>
/// 标记该类需要自动实现 IContextAware
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class ContextAwareAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace GFramework.SourceGenerators.Abstractions.Rule;
namespace GFramework.Core.SourceGenerators.Abstractions.Rule;

/// <summary>
/// 标记类需要自动推断并注入上下文相关字段。
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class GetAllAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace GFramework.SourceGenerators.Abstractions.Rule;
namespace GFramework.Core.SourceGenerators.Abstractions.Rule;

/// <summary>
/// 标记字段需要自动注入单个模型实例。
/// </summary>
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class GetModelAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace GFramework.SourceGenerators.Abstractions.Rule;
namespace GFramework.Core.SourceGenerators.Abstractions.Rule;

/// <summary>
/// 标记字段需要自动注入模型集合。
/// </summary>
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class GetModelsAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace GFramework.SourceGenerators.Abstractions.Rule;
namespace GFramework.Core.SourceGenerators.Abstractions.Rule;

/// <summary>
/// 标记字段需要自动注入单个服务实例。
/// </summary>
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class GetServiceAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace GFramework.SourceGenerators.Abstractions.Rule;
namespace GFramework.Core.SourceGenerators.Abstractions.Rule;

/// <summary>
/// 标记字段需要自动注入服务集合。
/// </summary>
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class GetServicesAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace GFramework.SourceGenerators.Abstractions.Rule;
namespace GFramework.Core.SourceGenerators.Abstractions.Rule;

/// <summary>
/// 标记字段需要自动注入单个系统实例。
/// </summary>
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class GetSystemAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace GFramework.Core.SourceGenerators.Abstractions.Rule;

/// <summary>
/// 标记字段需要自动注入系统集合。
/// </summary>
/// <remarks>
/// Source Generator 会为标记字段生成从当前架构上下文收集系统实例的注入代码,用于避免在组件内部重复书写
/// <c>GetSystems()</c> 一类的样板访问逻辑。
/// 被标记字段应声明为可承载多个系统实例的类型,例如 <c>IEnumerable&lt;ISystem&gt;</c> 或兼容集合接口。
/// </remarks>
/// <example>
/// <code>
/// public partial class CombatPanel : IContextAware
/// {
/// [GetSystems]
/// private IEnumerable&lt;ISystem&gt; _systems = Array.Empty&lt;ISystem&gt;();
/// }
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class GetSystemsAttribute : Attribute
{
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace GFramework.SourceGenerators.Abstractions.Rule;
namespace GFramework.Core.SourceGenerators.Abstractions.Rule;

/// <summary>
/// 标记字段需要自动注入工具集合。
/// </summary>
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class GetUtilitiesAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace GFramework.SourceGenerators.Abstractions.Rule;
namespace GFramework.Core.SourceGenerators.Abstractions.Rule;

/// <summary>
/// 标记字段需要自动注入单个工具实例。
/// </summary>
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class GetUtilityAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@
GF_ContextRegistration_001 | GFramework.SourceGenerators.rule | Warning | ContextRegistrationDiagnostics
GF_ContextRegistration_002 | GFramework.SourceGenerators.rule | Warning | ContextRegistrationDiagnostics
GF_ContextRegistration_003 | GFramework.SourceGenerators.rule | Warning | ContextRegistrationDiagnostics
GF_ConfigSchema_001 | GFramework.SourceGenerators.Config | Error | ConfigSchemaDiagnostics
GF_ConfigSchema_002 | GFramework.SourceGenerators.Config | Error | ConfigSchemaDiagnostics
GF_ConfigSchema_003 | GFramework.SourceGenerators.Config | Error | ConfigSchemaDiagnostics
GF_ConfigSchema_004 | GFramework.SourceGenerators.Config | Error | ConfigSchemaDiagnostics
GF_ConfigSchema_005 | GFramework.SourceGenerators.Config | Error | ConfigSchemaDiagnostics
GF_ConfigSchema_006 | GFramework.SourceGenerators.Config | Error | ConfigSchemaDiagnostics
GF_ConfigSchema_007 | GFramework.SourceGenerators.Config | Error | ConfigSchemaDiagnostics
GF_ConfigSchema_008 | GFramework.SourceGenerators.Config | Error | ConfigSchemaDiagnostics
GF_ConfigSchema_009 | GFramework.SourceGenerators.Config | Error | ConfigSchemaDiagnostics
GF_ConfigSchema_010 | GFramework.SourceGenerators.Config | Error | ConfigSchemaDiagnostics
GF_AutoModule_001 | GFramework.SourceGenerators.Architecture | Error | AutoRegisterModuleDiagnostics
GF_AutoModule_002 | GFramework.SourceGenerators.Architecture | Error | AutoRegisterModuleDiagnostics
GF_AutoModule_003 | GFramework.SourceGenerators.Architecture | Error | AutoRegisterModuleDiagnostics
Expand Down
Loading
Loading