From a7fa70e4fe97159b51fcfaed802bdcdf3970f856 Mon Sep 17 00:00:00 2001 From: gewuyou <95328647+GeWuYou@users.noreply.github.com> Date: Sat, 25 Apr 2026 15:29:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(core-tests):=20=E6=B8=85=E7=90=86=20LogCont?= =?UTF-8?q?extTests=20=E5=BC=82=E6=AD=A5=E7=AD=89=E5=BE=85=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复异步测试中的 await 链 MA0004 warning - 保持 LogContext 在线程隔离场景下的断言行为不变 --- GFramework.Core.Tests/Logging/LogContextTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GFramework.Core.Tests/Logging/LogContextTests.cs b/GFramework.Core.Tests/Logging/LogContextTests.cs index cdd1f731..59f468f6 100644 --- a/GFramework.Core.Tests/Logging/LogContextTests.cs +++ b/GFramework.Core.Tests/Logging/LogContextTests.cs @@ -157,7 +157,7 @@ public class LogContextTests using (LogContext.Push("TaskId", "Task1")) { task1Values.Add(LogContext.Current["TaskId"]); - await Task.Delay(50); + await Task.Delay(50).ConfigureAwait(false); task1Values.Add(LogContext.Current["TaskId"]); } }); @@ -167,12 +167,12 @@ public class LogContextTests using (LogContext.Push("TaskId", "Task2")) { task2Values.Add(LogContext.Current["TaskId"]); - await Task.Delay(50); + await Task.Delay(50).ConfigureAwait(false); task2Values.Add(LogContext.Current["TaskId"]); } }); - await Task.WhenAll(task1, task2); + await Task.WhenAll(task1, task2).ConfigureAwait(false); Assert.That(task1Values, Has.All.EqualTo("Task1")); Assert.That(task2Values, Has.All.EqualTo("Task2"));