GwWuYou ab5ea42350 feat(logging): 添加日志生成器功能
- 实现了 LoggerGenerator 源代码生成器,为标记 LogAttribute 的类自动生成日志字段
- 添加了 LogAttribute 特性,支持配置日志分类、字段名、访问修饰符和静态属性
- 创建了 Diagnostics 静态类,定义 GFLOG001 诊断规则检查 partial 类声明
- 集成 Microsoft.CodeAnalysis 包,启用增量生成器和扩展分析器规则
- 生成的代码包含命名空间、类名和日志字段的完整实现
2025-12-23 21:04:53 +08:00

26 lines
858 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.CodeAnalysis;
namespace GFramework.Generator.generator.logging;
/// <summary>
/// 提供诊断描述符的静态类用于GFramework日志生成器的编译时检查
/// </summary>
internal static class Diagnostics
{
/// <summary>
/// 定义一个诊断描述符,用于检查使用[Log]特性的类是否声明为partial
/// </summary>
/// <remarks>
/// 当类使用[Log]特性但未声明为partial时编译器将报告此错误
/// </remarks>
public static readonly DiagnosticDescriptor MustBePartial =
new(
id: "GFLOG001",
title: "Class must be partial",
messageFormat: "Class '{0}' must be declared partial to use [Log]",
category: "GFramework.Logging",
DiagnosticSeverity.Error,
isEnabledByDefault: true
);
}