mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 新增 GF_Rule_001 诊断规则,要求类必须实现 IContextAware 接口 - 创建 ContextAwareDiagnostic 类定义诊断规则元数据 - 修改 ContextAwareGenerator 实现 IContextAware 接口检查 - 优化生成器代码结构,添加候选类查找和输出生成功能 - 更新 AnalyzerReleases.Unshipped.md 文档 - 调整测试代码以适配新的诊断规则 - 修复日志诊断规则的命名空间大小写错误
28 lines
860 B
C#
28 lines
860 B
C#
using Microsoft.CodeAnalysis;
|
|
|
|
namespace GFramework.SourceGenerators.rule;
|
|
|
|
/// <summary>
|
|
/// 提供与上下文感知相关的诊断规则定义
|
|
/// </summary>
|
|
public static class ContextAwareDiagnostic
|
|
{
|
|
/// <summary>
|
|
/// 定义类必须实现IContextAware接口的诊断规则
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// 诊断ID: GF_Rule_001
|
|
/// 诊断类别: GFramework.SourceGenerators.rule
|
|
/// 严重级别: 错误
|
|
/// 启用状态: true
|
|
/// 消息格式: "Class '{0}' must implement IContextAware"
|
|
/// </remarks>
|
|
public static readonly DiagnosticDescriptor ClassMustImplementIContextAware = new(
|
|
"GF_Rule_001",
|
|
"Class must implement IContextAware",
|
|
"Class '{0}' must implement IContextAware",
|
|
"GFramework.SourceGenerators.rule",
|
|
DiagnosticSeverity.Error,
|
|
true
|
|
);
|
|
} |