diff --git a/Runtime/Autopilot.cs b/Runtime/Autopilot.cs
index c41a67d..c27254f 100644
--- a/Runtime/Autopilot.cs
+++ b/Runtime/Autopilot.cs
@@ -1,9 +1,8 @@
-// Copyright (c) 2023-2024 DeNA Co., Ltd.
+// Copyright (c) 2023-2025 DeNA Co., Ltd.
// This software is released under the MIT License.
using System;
using System.Collections;
-using System.Threading;
using Cysharp.Threading.Tasks;
using DeNA.Anjin.Settings;
using DeNA.Anjin.Utilities;
@@ -28,10 +27,9 @@ public interface ITerminatable
/// Log message string or terminate message
/// Stack trace when terminate by the log message
/// Call Reporter if true
- /// Cancellation token
/// A task awaits termination get completed
- UniTask TerminateAsync(ExitCode exitCode, string message = null, string stackTrace = null,
- bool reporting = true, CancellationToken token = default);
+ UniTaskVoid TerminateAsync(ExitCode exitCode, string message = null, string stackTrace = null,
+ bool reporting = true);
}
///
@@ -144,7 +142,7 @@ private void DispatchByLoadedScenes()
private IEnumerator Lifespan(int timeoutSec, ExitCode exitCode, string message)
{
yield return new WaitForSecondsRealtime(timeoutSec);
- yield return UniTask.ToCoroutine(() => TerminateAsync(exitCode, message));
+ TerminateAsync(exitCode, message).Forget();
}
private void OnDestroy()
@@ -157,8 +155,8 @@ private void OnDestroy()
}
///
- public async UniTask TerminateAsync(ExitCode exitCode, string message = null, string stackTrace = null,
- bool reporting = true, CancellationToken token = default)
+ public async UniTaskVoid TerminateAsync(ExitCode exitCode, string message = null, string stackTrace = null,
+ bool reporting = true)
{
if (_isTerminating)
{
@@ -176,7 +174,7 @@ public async UniTask TerminateAsync(ExitCode exitCode, string message = null, st
if (reporting && _state.IsRunning && _settings.Reporter != null)
{
- await _settings.Reporter.PostReportAsync(message, stackTrace, exitCode, token);
+ await _settings.Reporter.PostReportAsync(message, stackTrace, exitCode);
}
Destroy(this.gameObject);
diff --git a/Tests/Runtime/AutopilotTest.cs b/Tests/Runtime/AutopilotTest.cs
index 1aebd55..28e72ed 100644
--- a/Tests/Runtime/AutopilotTest.cs
+++ b/Tests/Runtime/AutopilotTest.cs
@@ -97,7 +97,9 @@ public async Task TerminateAsync_DestroyedAutopilotAndAgentObjects()
var agents = AgentInspector.Instances;
Assume.That(agents, Is.Not.Empty, "Agents are running");
- await autopilot.TerminateAsync(ExitCode.Normally, reporting: false);
+#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
+ autopilot.TerminateAsync(ExitCode.Normally, reporting: false);
+#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await UniTask.NextFrame(); // wait for destroy
autopilot = Object.FindObjectOfType(); // re-find after terminated
@@ -138,7 +140,9 @@ public async Task TerminateAsync_NoReporting_NotCallReporter()
await UniTask.Delay(500); // wait for launch
var autopilot = Autopilot.Instance;
- await autopilot.TerminateAsync(ExitCode.Normally, null, null, false);
+#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
+ autopilot.TerminateAsync(ExitCode.Normally, null, null, false);
+#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
Assert.That(spyReporter.IsCalled, Is.False);
}
@@ -153,7 +157,9 @@ public async Task TerminateAsync_Reporting_CallReporter()
await UniTask.Delay(500); // wait for launch
var autopilot = Autopilot.Instance;
- await autopilot.TerminateAsync(ExitCode.Normally, "message", "stack trace", true);
+#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
+ autopilot.TerminateAsync(ExitCode.Normally, "message", "stack trace", true);
+#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
Assert.That(spyReporter.IsCalled, Is.True);
Assert.That(spyReporter.Arguments["exitCode"], Is.EqualTo("Normally"));
diff --git a/Tests/Runtime/TestDoubles/SpyTerminatable.cs b/Tests/Runtime/TestDoubles/SpyTerminatable.cs
index 4131de2..ca4632d 100644
--- a/Tests/Runtime/TestDoubles/SpyTerminatable.cs
+++ b/Tests/Runtime/TestDoubles/SpyTerminatable.cs
@@ -1,7 +1,6 @@
-// Copyright (c) 2023-2024 DeNA Co., Ltd.
+// Copyright (c) 2023-2025 DeNA Co., Ltd.
// This software is released under the MIT License.
-using System.Threading;
using Cysharp.Threading.Tasks;
namespace DeNA.Anjin.TestDoubles
@@ -14,8 +13,8 @@ public class SpyTerminatable : ITerminatable
public string CapturedStackTrace { get; private set; }
public bool CapturedReporting { get; private set; }
- public async UniTask TerminateAsync(ExitCode exitCode, string message = null, string stackTrace = null,
- bool reporting = true, CancellationToken token = default)
+ public async UniTaskVoid TerminateAsync(ExitCode exitCode, string message = null, string stackTrace = null,
+ bool reporting = true)
{
IsCalled = true;
CapturedExitCode = exitCode;