mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 03:04:29 +08:00
- 为 ValidateSymbol 方法添加 Compilation 参数以支持类型解析 - 实现基于 Compilation 的接口类型验证,替代字符串比较方式 - 添加源代码生成器跟踪诊断功能,便于调试生成过程 - 在 AttributeClassGeneratorBase 中增加详细的执行流程跟踪日志 - 更新诊断描述符配置,添加跟踪信息的诊断支持 - 优化 ContextAwareGenerator 中的接口验证逻辑
60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using Microsoft.CodeAnalysis;
|
|
|
|
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,
|
|
isEnabledByDefault: 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,
|
|
isEnabledByDefault: true
|
|
);
|
|
|
|
/// <summary>
|
|
/// 源代码生成器跟踪信息
|
|
/// </summary>
|
|
public static void Trace(SourceProductionContext context, string message)
|
|
{
|
|
context.ReportDiagnostic(Diagnostic.Create(
|
|
GeneratorTrace,
|
|
Location.None,
|
|
message));
|
|
}
|
|
} |