GeWuYou 0cf4945e78 docs(config): 添加游戏内容配置系统文档
- 新增 CQRS 架构模式详细文档,包括命令查询职责分离核心概念
- 添加命令、查询、处理器、请求分发器等基本用法示例
- 包含高级用法如通知、管道行为、流式处理等完整功能介绍
- 提供最佳实践指南和常见问题解决方案
- 添加游戏内容配置系统文档,涵盖 YAML 配置源文件和 JSON Schema 结构描述
- 包含推荐目录结构、Schema 示例和 YAML 示例配置
- 提供完整的接入模板,包括 csproj 配置、启动帮助器和运行时读取模板
- 添加 Godot 文本配置桥接、热重载和 Architecture 接入等高级功能说明
2026-04-16 21:01:01 +08:00

100 lines
3.9 KiB
C#

using GFramework.SourceGenerators.Common.Constants;
namespace GFramework.Core.SourceGenerators.Diagnostics;
/// <summary>
/// 提供 Context Get 注入生成器相关诊断。
/// </summary>
public static class ContextGetDiagnostics
{
private const string SourceGeneratorsRuleCategory = $"{PathContests.SourceGeneratorsPath}.Rule";
/// <summary>
/// 不支持在嵌套类中生成注入代码。
/// </summary>
public static readonly DiagnosticDescriptor NestedClassNotSupported = new(
"GF_ContextGet_001",
"Context Get injection does not support nested classes",
"Class '{0}' cannot use context Get injection inside a nested type",
SourceGeneratorsRuleCategory,
DiagnosticSeverity.Error,
true);
/// <summary>
/// 带注入语义的字段不能是静态字段。
/// </summary>
public static readonly DiagnosticDescriptor StaticFieldNotSupported = new(
"GF_ContextGet_002",
"Static field is not supported for context Get injection",
"Field '{0}' cannot be static when using generated context Get injection",
SourceGeneratorsRuleCategory,
DiagnosticSeverity.Error,
true);
/// <summary>
/// 带注入语义的字段不能是只读字段。
/// </summary>
public static readonly DiagnosticDescriptor ReadOnlyFieldNotSupported = new(
"GF_ContextGet_003",
"Readonly field is not supported for context Get injection",
"Field '{0}' cannot be readonly when using generated context Get injection",
SourceGeneratorsRuleCategory,
DiagnosticSeverity.Error,
true);
/// <summary>
/// 使用 <c>[GetAll]</c> 时,静态字段会被跳过且不会生成注入赋值。
/// </summary>
public static readonly DiagnosticDescriptor GetAllStaticFieldSkipped = new(
"GF_ContextGet_007",
"Static field will be skipped by [GetAll] context Get injection",
"Field '{0}' is static and will be skipped by [GetAll] context Get injection generation",
SourceGeneratorsRuleCategory,
DiagnosticSeverity.Warning,
true);
/// <summary>
/// 使用 <c>[GetAll]</c> 时,只读字段会被跳过且不会生成注入赋值。
/// </summary>
public static readonly DiagnosticDescriptor GetAllReadOnlyFieldSkipped = new(
"GF_ContextGet_008",
"Readonly field will be skipped by [GetAll] context Get injection",
"Field '{0}' is readonly and will be skipped by [GetAll] context Get injection generation",
SourceGeneratorsRuleCategory,
DiagnosticSeverity.Warning,
true);
/// <summary>
/// 字段类型与注入特性不匹配。
/// </summary>
public static readonly DiagnosticDescriptor InvalidBindingType = new(
"GF_ContextGet_004",
"Field type is not valid for the selected context Get attribute",
"Field '{0}' type '{1}' is not valid for [{2}]",
SourceGeneratorsRuleCategory,
DiagnosticSeverity.Error,
true);
/// <summary>
/// 使用 Context Get 注入的类型必须是上下文感知类型。
/// </summary>
public static readonly DiagnosticDescriptor ContextAwareTypeRequired = new(
"GF_ContextGet_005",
"Context-aware type is required",
"Class '{0}' must be context-aware to use generated context Get injection",
SourceGeneratorsRuleCategory,
DiagnosticSeverity.Error,
true);
/// <summary>
/// 一个字段不允许同时声明多个 Context Get 特性。
/// </summary>
public static readonly DiagnosticDescriptor MultipleBindingAttributesNotSupported = new(
"GF_ContextGet_006",
"Multiple context Get attributes are not supported on the same field",
"Field '{0}' cannot declare multiple generated context Get attributes",
SourceGeneratorsRuleCategory,
DiagnosticSeverity.Error,
true);
}