mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 08:44:29 +08:00
- 实现 project.godot 文件解析功能,支持 AutoLoad 和 Input Action 元数据提取 - 生成 AutoLoads 强类型访问入口,提供 GetRequiredNode 和 TryGetNode 方法 - 生成 InputActions 常量类,避免手写字符串魔法值 - 添加 AutoLoadAttribute 特性支持显式类型映射声明 - 实现标识符冲突检测和自动后缀追加机制 - 添加完整的诊断系统支持,包括类型继承检查和重复条目警告 - 创建 MSBuild 集成目标文件确保生成器正确加载 - 提供详细的 README 文档说明使用方法和最佳实践
31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
#nullable enable
|
|
namespace GFramework.Godot.SourceGenerators.Abstractions;
|
|
|
|
/// <summary>
|
|
/// 显式声明某个 Godot 节点类型与 <c>project.godot</c> 中 AutoLoad 名称之间的映射关系。
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// 当 AutoLoad 条目无法仅靠类型名唯一推断到 C# 节点类型时,
|
|
/// 可以通过该特性为生成器提供稳定的强类型映射入口。
|
|
/// </remarks>
|
|
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
|
|
public sealed class AutoLoadAttribute : Attribute
|
|
{
|
|
/// <summary>
|
|
/// 初始化 <see cref="AutoLoadAttribute" /> 的新实例。
|
|
/// </summary>
|
|
/// <param name="name">在 <c>project.godot</c> 中声明的 AutoLoad 名称。</param>
|
|
/// <exception cref="ArgumentNullException">
|
|
/// <paramref name="name" /> 为 <see langword="null" />。
|
|
/// </exception>
|
|
public AutoLoadAttribute(string name)
|
|
{
|
|
Name = name ?? throw new ArgumentNullException(nameof(name));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取在 <c>project.godot</c> 中声明的 AutoLoad 名称。
|
|
/// </summary>
|
|
public string Name { get; }
|
|
}
|