fix(logging): 修复源代码生成器中的日志属性引用错误

- 修正 GodotLoggerGenerator 中的属性元数据名称为正确的命名空间路径
- 更新 LoggerGenerator 中的属性引用从 GodotLogAttribute 改为 LogAttribute
- 修复 ConsoleLoggerFactory 的实例化方式,添加缺失的构造函数调用
- 统一日志属性名称格式,移除多余的 Godot 前缀
This commit is contained in:
GwWuYou 2025-12-25 22:09:52 +08:00
parent 4fbc067414
commit 378690a42c
2 changed files with 7 additions and 5 deletions

View File

@ -14,9 +14,11 @@ namespace GFramework.Godot.SourceGenerators.logging;
[Generator]
public sealed class GodotLoggerGenerator : IIncrementalGenerator
{
private const string AttributeMetadataName = "GFramework.SourceGenerators.Attributes.logging.GodotLogAttribute";
private const string AttributeMetadataName =
"GFramework.Godot.SourceGenerators.Attributes.logging.GodotLogAttribute";
private const string AttributeShortName = "GodotLogAttribute";
private const string AttributeShortNameWithoutSuffix = "Log";
private const string AttributeShortNameWithoutSuffix = "GodotLog";
/// <summary>
/// 初始化生成器,设置语法过滤和代码生成逻辑

View File

@ -17,8 +17,8 @@ namespace GFramework.SourceGenerators.logging;
[Generator]
public sealed class LoggerGenerator : IIncrementalGenerator
{
private const string AttributeMetadataName = "GFramework.SourceGenerators.Attributes.logging.GodotLogAttribute";
private const string AttributeShortName = "GodotLogAttribute";
private const string AttributeMetadataName = "GFramework.SourceGenerators.Attributes.logging.LogAttribute";
private const string AttributeShortName = "LogAttribute";
private const string AttributeShortNameWithoutSuffix = "Log";
/// <summary>
@ -163,7 +163,7 @@ public sealed class LoggerGenerator : IIncrementalGenerator
sb.AppendLine($" /// <summary>Auto-generated logger</summary>");
sb.AppendLine(
$" {access} {staticKeyword}readonly ILogger {fieldName} = " +
$"new ConsoleLoggerFactory.GetLogger(\"{name}\");");
$"new ConsoleLoggerFactory().GetLogger(\"{name}\");");
sb.AppendLine(" }");
if (ns is not null)