test(Godot): 添加项目元数据生成器测试

- 验证 AutoLoad 和 Input Action 强类型入口生成
- 测试非节点类型上的 AutoLoad 标记诊断
- 验证输入动作标识符冲突处理和后缀追加
- 测试多个显式映射指向相同 AutoLoad 的重复检测
- 验证不同命名空间同名节点类型的冲突处理
- 测试 AutoLoad 标识符冲突的诊断和后缀追加
- 验证项目文件中重复 AutoLoad 条目的处理
- 测试重复输入动作条目的诊断和保留机制
This commit is contained in:
GeWuYou 2026-04-14 09:23:49 +08:00
parent 833a295b84
commit bb7abc0d8f

View File

@ -14,56 +14,20 @@ public class GodotProjectMetadataGeneratorTests
[Test]
public void Run_Should_Generate_AutoLoads_And_InputActions()
{
const string source = """
using System;
var source = CreateSource(
"""
namespace TestApp
{
using GFramework.Godot.SourceGenerators.Abstractions;
using Godot;
namespace GFramework.Godot.SourceGenerators.Abstractions
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class AutoLoadAttribute : Attribute
{
public AutoLoadAttribute(string name)
{
Name = name;
}
public string Name { get; }
}
}
namespace Godot
{
public class MainLoop
{
}
public class Node
{
public T? GetNodeOrNull<T>(string path) where T : Node => default;
}
public sealed class SceneTree : MainLoop
{
public Node? Root { get; set; }
}
public static class Engine
{
public static MainLoop? GetMainLoop() => default;
}
}
namespace TestApp
{
using GFramework.Godot.SourceGenerators.Abstractions;
using Godot;
[AutoLoad("GameServices")]
public partial class GameServices : Node
{
}
}
""";
[AutoLoad("GameServices")]
public partial class GameServices : Node
{
}
}
""",
includeAutoLoadAttribute: true);
const string projectFile = """
[autoload]