diff --git a/GFramework.Game.Abstractions/assets/IAssetCatalogSystem.cs b/GFramework.Game.Abstractions/assets/IAssetCatalogSystem.cs index cab53ee..ff38ba1 100644 --- a/GFramework.Game.Abstractions/assets/IAssetCatalogSystem.cs +++ b/GFramework.Game.Abstractions/assets/IAssetCatalogSystem.cs @@ -34,14 +34,12 @@ public interface IAssetCatalogSystem : ISystem /// /// 场景单元的唯一标识键 /// 场景单元资源的路径 - /// 当指定的键已存在时抛出异常 public void RegisterSceneUnit(string key, string path); /// /// 通过资产目录映射注册场景单元 /// /// 包含场景单元信息的资产目录映射对象 - /// 当映射ID不是SceneUnitId类型或键已存在时抛出异常 public void RegisterSceneUnit(AssetCatalog.AssetCatalogMapping mapping); /// @@ -49,14 +47,12 @@ public interface IAssetCatalogSystem : ISystem /// /// 场景页面的唯一标识键 /// 场景页面资源路径 - /// 当键已存在时抛出异常 void RegisterScenePage(string key, string path); /// /// 通过资产目录映射注册场景页面 /// /// 包含场景页面信息的资产目录映射对象 - /// 当映射ID不是ScenePageId类型或键已存在时抛出异常 void RegisterScenePage(AssetCatalog.AssetCatalogMapping mapping); /// diff --git a/GFramework.Godot.SourceGenerators.Abstractions/GFramework.Godot.SourceGenerators.Abstractions.csproj b/GFramework.Godot.SourceGenerators.Abstractions/GFramework.Godot.SourceGenerators.Abstractions.csproj index 3e7de14..7acd9a3 100644 --- a/GFramework.Godot.SourceGenerators.Abstractions/GFramework.Godot.SourceGenerators.Abstractions.csproj +++ b/GFramework.Godot.SourceGenerators.Abstractions/GFramework.Godot.SourceGenerators.Abstractions.csproj @@ -8,6 +8,7 @@ false true T:System.Diagnostics.CodeAnalysis.NotNullWhenAttribute + enable diff --git a/GFramework.SourceGenerators.Tests/core/GeneratorTest.cs b/GFramework.SourceGenerators.Tests/core/GeneratorTest.cs index 4dfbc09..b78411d 100644 --- a/GFramework.SourceGenerators.Tests/core/GeneratorTest.cs +++ b/GFramework.SourceGenerators.Tests/core/GeneratorTest.cs @@ -25,7 +25,8 @@ public static class GeneratorTest TestState = { Sources = { source } - } + }, + DisabledDiagnostics = { "GF_Common_Trace_001" } }; // 添加期望的生成源文件到测试状态中 diff --git a/GFramework.SourceGenerators.Tests/rule/ContextAwareGeneratorTests.cs b/GFramework.SourceGenerators.Tests/rule/ContextAwareGeneratorTests.cs index 6727f4a..971c18d 100644 --- a/GFramework.SourceGenerators.Tests/rule/ContextAwareGeneratorTests.cs +++ b/GFramework.SourceGenerators.Tests/rule/ContextAwareGeneratorTests.cs @@ -4,18 +4,11 @@ using NUnit.Framework; namespace GFramework.SourceGenerators.Tests.rule; -/// -/// 测试ContextAwareGenerator源代码生成器的功能 -/// [TestFixture] public class ContextAwareGeneratorTests { - /// - /// 测试ContextAware代码生成功能 - /// 验证当使用[ContextAware]特性标记的类能够正确生成上下文感知的相关代码 - /// [Test] - public Task Generates_ContextAware_Code() + public async Task Generates_ContextAware_Code() { const string source = """ using System; @@ -33,7 +26,8 @@ public class ContextAwareGeneratorTests using GFramework.SourceGenerators.Abstractions.rule; [ContextAware] - public partial class MyRule: GFramework.Core.Abstractions.rule.IContextAware + public partial class MyRule + : GFramework.Core.Abstractions.rule.IContextAware { } } @@ -44,7 +38,8 @@ public class ContextAwareGeneratorTests { public interface IContextAware { - void SetContext(GFramework.Core.Abstractions.architecture.IArchitectureContext context); + void SetContext( + GFramework.Core.Abstractions.architecture.IArchitectureContext context); } } @@ -75,19 +70,14 @@ public class ContextAwareGeneratorTests } """; - Assert.DoesNotThrowAsync(async () => - { - await GeneratorTest.RunAsync( - source + "\n" + frameworkStub, - ("MyRule.ContextAware.g.cs", expected) - ); - }); - - return Task.CompletedTask; + await GeneratorTest.RunAsync( + source + "\n" + frameworkStub, + ("MyRule.ContextAware.g.cs", expected) + ); } [Test] - public Task Generates_ContextAware_Code_When_Interface_Inherits_IContextAware() + public async Task Generates_ContextAware_Code_When_Interface_Inherits_IContextAware() { const string source = """ using System; @@ -105,7 +95,6 @@ public class ContextAwareGeneratorTests using GFramework.SourceGenerators.Abstractions.rule; using GFramework.Core.Abstractions.rule; - // 间接接口:继承自 IContextAware public interface IMyRuleContextAware : IContextAware { } @@ -122,7 +111,8 @@ public class ContextAwareGeneratorTests { public interface IContextAware { - void SetContext(GFramework.Core.Abstractions.architecture.IArchitectureContext context); + void SetContext( + GFramework.Core.Abstractions.architecture.IArchitectureContext context); } } @@ -153,14 +143,9 @@ public class ContextAwareGeneratorTests } """; - Assert.DoesNotThrowAsync(async () => - { - await GeneratorTest.RunAsync( - source + "\n" + frameworkStub, - ("MyRule.ContextAware.g.cs", expected) - ); - }); - - return Task.CompletedTask; + await GeneratorTest.RunAsync( + source + "\n" + frameworkStub, + ("MyRule.ContextAware.g.cs", expected) + ); } } \ No newline at end of file