diff --git a/Controllers/SimApiBaseController.cs b/Controllers/SimApiBaseController.cs
index d923ed5..37e4e30 100644
--- a/Controllers/SimApiBaseController.cs
+++ b/Controllers/SimApiBaseController.cs
@@ -1,4 +1,5 @@
-using SimApi.Communications;
+using System.Diagnostics.CodeAnalysis;
+using SimApi.Communications;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
@@ -53,7 +54,7 @@ public class SimApiBaseController : Controller
/// 检测条件
/// 错误代码
/// 错误描述
- protected static void ErrorWhen(bool condition, int code = 400, string message = "")
+ protected static void ErrorWhen([DoesNotReturnIf(true)] bool condition, int code = 400, string message = "")
{
if (condition)
{
@@ -68,7 +69,7 @@ public class SimApiBaseController : Controller
/// 检测条件
/// 错误代码
/// 错误描述
- protected static void ErrorWhenTrue(bool condition, int code = 400, string message = "")
+ protected static void ErrorWhenTrue([DoesNotReturnIf(true)] bool condition, int code = 400, string message = "")
{
ErrorWhen(condition, code, message);
}
@@ -80,7 +81,7 @@ public class SimApiBaseController : Controller
///
///
///
- protected static void ErrorWhenFalse(bool condition, int code = 400, string message = "")
+ protected static void ErrorWhenFalse([DoesNotReturnIf(false)] bool condition, int code = 400, string message = "")
{
ErrorWhen(!condition, code, message);
}
@@ -91,7 +92,7 @@ public class SimApiBaseController : Controller
/// 检测条件
/// 错误代码
/// 错误描述
- protected static void ErrorWhenNull(object? condition, int code = 404, string message = "请求的资源不存在")
+ protected static void ErrorWhenNull([NotNull] object? condition, int code = 404, string message = "请求的资源不存在")
{
ErrorWhen(condition == null, code, message);
}