mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 统一调整代码注释的缩进格式,保持文档注释的一致性 - 简化对象初始化语法,移除不必要的参数名称指定 - 优化条件语句结构,移除多余的花括号 - 调整方法实现格式,使用表达式主体语法简化代码 - 标准化代码缩进和空格使用,提升代码可读性 - [skip ci]
60 lines
1.7 KiB
C#
60 lines
1.7 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,
|
|
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));
|
|
}
|
|
} |