Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions GameFrameX.Foundation.Extensions/NullObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ public static NullObject<T> Null
/// <remarks>
/// Compares the current object with another object.
/// </remarks>
/// <param name="value">要比较的对象 / The object to compare with.</param>
/// <returns>一个整数,指示当前对象与 <paramref name="value" /> 的相对顺序 / An integer indicating the relative order of the current object and <paramref name="value" />.</returns>
/// <param name="obj">要比较的对象 / The object to compare with.</param>
/// <returns>一个整数,指示当前对象与 <paramref name="obj" /> 的相对顺序 / An integer indicating the relative order of the current object and <paramref name="obj" />.</returns>
/// <exception cref="ArgumentException">当 Item 为 null 且无法进行比较时抛出 / Thrown when Item is null and cannot be compared.</exception>
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<T> nullObject)
if (obj is NullObject<T> nullObject)
{
if (Item is null && nullObject.Item is null)
{
Expand All @@ -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));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion GameFrameX.Foundation.Tests/Extensions/NullObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down