mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 将 LogAttribute 的 Category 属性改为可设置 - 添加了无参构造函数支持 - 移除了部分无效的诊断检查代码 - 为 LoggerGenerator 添加了可空引用类型支持 - 使用 switch 表达式简化参数解析逻辑 - 优化了命名参数获取方法的实现
32 lines
1009 B
C#
32 lines
1009 B
C#
#nullable enable
|
||
using System;
|
||
|
||
namespace GFramework.Generator.Attributes.generator.logging;
|
||
|
||
/// <summary>
|
||
/// 标注在类上,Source Generator 会为该类自动生成一个日志记录器字段。
|
||
/// </summary>
|
||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||
public sealed class LogAttribute : Attribute
|
||
{
|
||
/// <summary>日志分类名(默认使用类名)</summary>
|
||
public string? Category { get; set; }
|
||
|
||
/// <summary>生成字段名</summary>
|
||
public string FieldName { get; set; } = "_log";
|
||
|
||
/// <summary>是否生成 static 字段</summary>
|
||
public bool IsStatic { get; set; } = true;
|
||
|
||
/// <summary>访问修饰符</summary>
|
||
public string AccessModifier { get; set; } = "private";
|
||
public LogAttribute() { }
|
||
/// <summary>
|
||
/// 初始化 LogAttribute 类的新实例
|
||
/// </summary>
|
||
/// <param name="category">日志分类名,默认使用类名</param>
|
||
public LogAttribute(string? category)
|
||
{
|
||
Category = category;
|
||
}
|
||
} |