From 749a95fe801963323be3d544192d6051413dc88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JasonXuDeveloper=20-=20=E5=82=91?= Date: Sat, 31 Jan 2026 09:38:44 +1100 Subject: [PATCH] fix(util): use using statement for JAction in Reset_AllowsReuse test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes CodeQL alert cs/dispose-not-called-on-throw. If Execute(), Reset(), or Do() threw an exception, Dispose() would not be called. Using a using declaration ensures the JAction is disposed even if an exception occurs. Co-Authored-By: Claude Opus 4.5 Signed-off-by: JasonXuDeveloper - 傑 --- .../Tests/Editor/JActionTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/UnityProject/Packages/com.jasonxudeveloper.jengine.util/Tests/Editor/JActionTests.cs b/UnityProject/Packages/com.jasonxudeveloper.jengine.util/Tests/Editor/JActionTests.cs index 077afb47..bca77b7c 100644 --- a/UnityProject/Packages/com.jasonxudeveloper.jengine.util/Tests/Editor/JActionTests.cs +++ b/UnityProject/Packages/com.jasonxudeveloper.jengine.util/Tests/Editor/JActionTests.cs @@ -473,7 +473,7 @@ public void Reset_AllowsReuse() { int counter = 0; - var action = JAction.Create() + using var action = JAction.Create() .Do(() => counter++); action.Execute(); @@ -484,8 +484,6 @@ public void Reset_AllowsReuse() .Execute(); Assert.AreEqual(11, counter); - - action.Dispose(); } #endregion