fix(generator): 修复代码生成器属性路径和匹配逻辑

- 修正了枚举扩展生成器中属性的完整名称路径
- 修正了日志生成器中属性的完整名称路径
- 改进了属性匹配逻辑,添加了空值检查
- 增强了属性类名匹配,支持简短名称匹配
This commit is contained in:
GwWuYou 2025-12-23 23:03:31 +08:00
parent 1f370dfdc9
commit ce8dca3631
2 changed files with 9 additions and 3 deletions

View File

@ -10,7 +10,7 @@ namespace GFramework.Generator.generator.enums;
[Generator]
public class EnumExtensionsGenerator : IIncrementalGenerator
{
private const string AttributeFullName = "GFramework.Generator.Attributes.GenerateEnumExtensionsAttribute";
private const string AttributeFullName = "GFramework.Generator.Attributes.generator.enums.GenerateEnumExtensionsAttribute";
public void Initialize(IncrementalGeneratorInitializationContext context)
{

View File

@ -14,7 +14,7 @@ namespace GFramework.Generator.generator.logging
public sealed class LoggerGenerator : IIncrementalGenerator
{
private const string AttributeMetadataName =
"GFramework.Generator.Attributes.LogAttribute";
"GFramework.Generator.Attributes.generator.logging.LogAttribute";
/// <summary>
/// 初始化增量生成器
@ -85,7 +85,13 @@ namespace GFramework.Generator.generator.logging
var attr = classSymbol.GetAttributes()
.FirstOrDefault(a =>
a.AttributeClass?.ToDisplayString() == AttributeMetadataName);
{
var c = a.AttributeClass;
if (c is null) return false;
return c.ToDisplayString() == AttributeMetadataName
|| c.Name == "LogAttribute";
});
if (attr is null)
{