mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-04-01 02:56:44 +08:00
- 实现 BindNodeSignalGenerator 用于生成节点信号绑定与解绑逻辑 - 实现 GetNodeGenerator 用于生成 Godot 节点获取注入逻辑 - 添加 BindNodeSignalDiagnostics 提供详细的诊断错误信息 - 集成到 AnalyzerReleases.Unshipped.md 追踪新的分析规则 - 支持 [BindNodeSignal] 属性的方法自动生成事件绑定代码 - 支持 [GetNode] 属性的字段自动生成节点获取代码 - 提供生命周期方法集成的智能提示和验证功能
75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
namespace GFramework.SourceGenerators.Common.Diagnostics;
|
|
|
|
/// <summary>
|
|
/// 提供通用诊断描述符的静态类
|
|
/// </summary>
|
|
public static class CommonDiagnostics
|
|
{
|
|
/// <summary>
|
|
/// 定义类必须为partial的诊断描述符
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// 诊断ID: GF001
|
|
/// 诊断消息: "Class '{0}' must be declared partial for code generation"
|
|
/// 分类: GFramework.Common
|
|
/// 严重性: Error
|
|
/// 是否启用: true
|
|
/// </remarks>
|
|
public static readonly DiagnosticDescriptor ClassMustBePartial =
|
|
new(
|
|
"GF_Common_Class_001",
|
|
"Class must be partial",
|
|
"Class '{0}' must be declared partial for code generation",
|
|
"GFramework.Common",
|
|
DiagnosticSeverity.Error,
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// 定义生成方法名与用户代码冲突的诊断描述符。
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// 该诊断用于保护生成器保留的方法名,避免用户代码手动声明了相同零参数方法时出现重复成员错误,
|
|
/// 并使多个生成器可以复用同一条一致的冲突报告规则。
|
|
/// </remarks>
|
|
public static readonly DiagnosticDescriptor GeneratedMethodNameConflict =
|
|
new(
|
|
"GF_Common_Class_002",
|
|
"Generated method name conflicts with an existing member",
|
|
"Class '{0}' already defines method '{1}()', which conflicts with generated code",
|
|
"GFramework.Common",
|
|
DiagnosticSeverity.Error,
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// 定义源代码生成器跟踪信息的诊断描述符
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// 诊断ID: GF_Common_Trace_001
|
|
/// 诊断消息: "{0}"
|
|
/// 分类: GFramework.Trace
|
|
/// 严重性: Info
|
|
/// 是否启用: true
|
|
/// </remarks>
|
|
public static readonly DiagnosticDescriptor GeneratorTrace =
|
|
new(
|
|
"GF_Common_Trace_001",
|
|
"Source generator trace",
|
|
"{0}",
|
|
"GFramework.Trace",
|
|
DiagnosticSeverity.Info,
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// 源代码生成器跟踪信息
|
|
/// </summary>
|
|
public static void Trace(SourceProductionContext context, string message)
|
|
{
|
|
context.ReportDiagnostic(Diagnostic.Create(
|
|
GeneratorTrace,
|
|
Location.None,
|
|
message));
|
|
}
|
|
} |