From 1e0bd010c5f411c76bd5c607cdcf381c37f735e6 Mon Sep 17 00:00:00 2001 From: Blank Date: Wed, 29 Jul 2026 20:44:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(extensions):=20=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=20NullObject.CompareTo=20=E5=8F=82=E6=95=B0=20value=20?= =?UTF-8?q?=E4=B8=BA=20obj?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Linear: GFX-194 --- GameFrameX.Foundation.Extensions/NullObject.cs | 14 +++++++------- .../Extensions/NullObjectTests.cs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/GameFrameX.Foundation.Extensions/NullObject.cs b/GameFrameX.Foundation.Extensions/NullObject.cs index 046e2f0..fd9e2b6 100644 --- a/GameFrameX.Foundation.Extensions/NullObject.cs +++ b/GameFrameX.Foundation.Extensions/NullObject.cs @@ -83,17 +83,17 @@ public static NullObject Null /// /// Compares the current object with another object. /// - /// 要比较的对象 / The object to compare with. - /// 一个整数,指示当前对象与 的相对顺序 / An integer indicating the relative order of the current object and . + /// 要比较的对象 / The object to compare with. + /// 一个整数,指示当前对象与 的相对顺序 / An integer indicating the relative order of the current object and . /// 当 Item 为 null 且无法进行比较时抛出 / Thrown when Item is null and cannot be compared. - public int CompareTo(object value) + public int CompareTo(object obj) { - if (value is null) + if (obj is null) { return Item is null ? 0 : 1; } - if (value is NullObject nullObject) + if (obj is NullObject nullObject) { if (Item is null && nullObject.Item is null) { @@ -118,12 +118,12 @@ public int CompareTo(object value) return string.Compare(Item?.ToString(), nullObject.Item?.ToString(), StringComparison.Ordinal); } - if (value is T directValue) + if (obj is T directValue) { return CompareTo(directValue); } - throw new ArgumentException(LocalizationService.GetString(LocalizationKeys.Exceptions.ObjectTypeMismatch), nameof(value)); + throw new ArgumentException(LocalizationService.GetString(LocalizationKeys.Exceptions.ObjectTypeMismatch), nameof(obj)); } /// diff --git a/GameFrameX.Foundation.Tests/Extensions/NullObjectTests.cs b/GameFrameX.Foundation.Tests/Extensions/NullObjectTests.cs index c4c34e4..256b746 100644 --- a/GameFrameX.Foundation.Tests/Extensions/NullObjectTests.cs +++ b/GameFrameX.Foundation.Tests/Extensions/NullObjectTests.cs @@ -155,7 +155,7 @@ public void CompareTo_Object_WithIncompatibleType_ShouldThrowArgumentException() // 验证异常消息不为空且包含参数名(支持中英文本地化) Assert.NotNull(exception.Message); Assert.True(exception.Message.Length > 0); - Assert.Equal("value", exception.ParamName); + Assert.Equal("obj", exception.ParamName); } [Fact]