mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-12 22:03:30 +08:00
test(Godot): 添加项目元数据生成器测试
- 验证 AutoLoad 和 Input Action 强类型入口生成 - 测试非节点类型上的 AutoLoad 标记诊断 - 验证输入动作标识符冲突处理和后缀追加 - 测试多个显式映射指向相同 AutoLoad 的重复检测 - 验证不同命名空间同名节点类型的冲突处理 - 测试 AutoLoad 标识符冲突的诊断和后缀追加 - 验证项目文件中重复 AutoLoad 条目的处理 - 测试重复输入动作条目的诊断和保留机制
This commit is contained in:
parent
833a295b84
commit
bb7abc0d8f
@ -14,56 +14,20 @@ public class GodotProjectMetadataGeneratorTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void Run_Should_Generate_AutoLoads_And_InputActions()
|
public void Run_Should_Generate_AutoLoads_And_InputActions()
|
||||||
{
|
{
|
||||||
const string source = """
|
var source = CreateSource(
|
||||||
using System;
|
"""
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
using GFramework.Godot.SourceGenerators.Abstractions;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
namespace GFramework.Godot.SourceGenerators.Abstractions
|
[AutoLoad("GameServices")]
|
||||||
{
|
public partial class GameServices : Node
|
||||||
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
|
{
|
||||||
public sealed class AutoLoadAttribute : Attribute
|
}
|
||||||
{
|
}
|
||||||
public AutoLoadAttribute(string name)
|
""",
|
||||||
{
|
includeAutoLoadAttribute: true);
|
||||||
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
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
""";
|
|
||||||
|
|
||||||
const string projectFile = """
|
const string projectFile = """
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user