From bb7abc0d8f32264a92e675a6db87c1c5f21749dc Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Tue, 14 Apr 2026 09:23:49 +0800 Subject: [PATCH] =?UTF-8?q?test(Godot):=20=E6=B7=BB=E5=8A=A0=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=85=83=E6=95=B0=E6=8D=AE=E7=94=9F=E6=88=90=E5=99=A8?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 验证 AutoLoad 和 Input Action 强类型入口生成 - 测试非节点类型上的 AutoLoad 标记诊断 - 验证输入动作标识符冲突处理和后缀追加 - 测试多个显式映射指向相同 AutoLoad 的重复检测 - 验证不同命名空间同名节点类型的冲突处理 - 测试 AutoLoad 标识符冲突的诊断和后缀追加 - 验证项目文件中重复 AutoLoad 条目的处理 - 测试重复输入动作条目的诊断和保留机制 --- .../GodotProjectMetadataGeneratorTests.cs | 62 ++++--------------- 1 file changed, 13 insertions(+), 49 deletions(-) diff --git a/GFramework.Godot.SourceGenerators.Tests/Project/GodotProjectMetadataGeneratorTests.cs b/GFramework.Godot.SourceGenerators.Tests/Project/GodotProjectMetadataGeneratorTests.cs index 63265bd2..96dbe30f 100644 --- a/GFramework.Godot.SourceGenerators.Tests/Project/GodotProjectMetadataGeneratorTests.cs +++ b/GFramework.Godot.SourceGenerators.Tests/Project/GodotProjectMetadataGeneratorTests.cs @@ -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(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]