diff --git a/build/_build.csproj b/build/_build.csproj
index b1965fa..1ef2041 100644
--- a/build/_build.csproj
+++ b/build/_build.csproj
@@ -1,18 +1,18 @@
-
+
-
- Exe
- net8.0
-
- CS0649;CS0169;CA1050;CA1822;CA2211;IDE1006
- ..
- ..
- 1
- false
-
+
+ Exe
+ net10.0
+
+ CS0649;CS0169;CA1050;CA1822;CA2211;IDE1006
+ ..
+ ..
+ 1
+ false
+
-
-
-
+
+
+
diff --git a/build/configureawait.props b/build/configureawait.props
index b0aacc7..da15bcf 100644
--- a/build/configureawait.props
+++ b/build/configureawait.props
@@ -1,7 +1,7 @@
-
+
All
runtime; build; native; contentfiles; analyzers
diff --git a/global.json b/global.json
index 2c63c08..1e7fdfa 100644
--- a/global.json
+++ b/global.json
@@ -1,2 +1,6 @@
{
+ "sdk": {
+ "version": "10.0.100",
+ "rollForward": "latestMinor"
+ }
}
diff --git a/src/LuYao.Common/LuYao.Common.csproj b/src/LuYao.Common/LuYao.Common.csproj
index 5849dcd..7509be8 100644
--- a/src/LuYao.Common/LuYao.Common.csproj
+++ b/src/LuYao.Common/LuYao.Common.csproj
@@ -2,7 +2,7 @@
- net45;net461;netstandard2.0;netstandard2.1;net6.0;net8.0
+ net45;net461;netstandard2.0;netstandard2.1;net6.0;net8.0;net9.0;net10.0
LuYao
LuYao.Common
latest
diff --git a/src/LuYao.Text.Json.Jint/LuYao.Text.Json.Jint.csproj b/src/LuYao.Text.Json.Jint/LuYao.Text.Json.Jint.csproj
index 8bdeb02..4e5a3db 100644
--- a/src/LuYao.Text.Json.Jint/LuYao.Text.Json.Jint.csproj
+++ b/src/LuYao.Text.Json.Jint/LuYao.Text.Json.Jint.csproj
@@ -3,22 +3,20 @@
- net461;netstandard2.0;netstandard2.1;net6.0;net8.0
+ net461;netstandard2.0;netstandard2.1;net6.0;net8.0;net9.0;net10.0
latest
True
LuYao.Text.Json
True
..\..\docs\luyao.snk
-
+
-
-
-
+
+
-
diff --git a/src/LuYao.Text.Json/LuYao.Text.Json.csproj b/src/LuYao.Text.Json/LuYao.Text.Json.csproj
index e7538f8..a48e99d 100644
--- a/src/LuYao.Text.Json/LuYao.Text.Json.csproj
+++ b/src/LuYao.Text.Json/LuYao.Text.Json.csproj
@@ -3,7 +3,7 @@
- net45;net461;netstandard2.0;netstandard2.1;net6.0;net8.0
+ net45;net461;netstandard2.0;netstandard2.1;net6.0;net8.0;net9.0;net10.0
latest
True
True
@@ -15,7 +15,7 @@
-
+
diff --git a/tests/LuYao.Common.UnitTests/Collections/Concurrent/AsyncQueueTests.cs b/tests/LuYao.Common.UnitTests/Collections/Concurrent/AsyncQueueTests.cs
index 165b19d..1e0636a 100644
--- a/tests/LuYao.Common.UnitTests/Collections/Concurrent/AsyncQueueTests.cs
+++ b/tests/LuYao.Common.UnitTests/Collections/Concurrent/AsyncQueueTests.cs
@@ -53,7 +53,7 @@ public async Task DequeueAsync_NoItem_CancellationTokenTriggersException()
cts.Cancel();
// Act & Assert
- await Assert.ThrowsExceptionAsync(async () =>
+ await Assert.ThrowsExactlyAsync(async () =>
{
await queue.DequeueAsync(cts.Token);
});
diff --git a/tests/LuYao.Common.UnitTests/Collections/EnumerableExtensionsTests.cs b/tests/LuYao.Common.UnitTests/Collections/EnumerableExtensionsTests.cs
index d6d3c07..6e4c894 100644
--- a/tests/LuYao.Common.UnitTests/Collections/EnumerableExtensionsTests.cs
+++ b/tests/LuYao.Common.UnitTests/Collections/EnumerableExtensionsTests.cs
@@ -63,26 +63,23 @@ public void SplitToBatch_ListWithRemainder_ReturnsLastBatchWithFewerItems()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentNullException))]
public void SplitToBatch_NullSource_ThrowsArgumentNullException()
{
List? input = null;
- _ = input.SplitToBatch(2).ToList();
+ Assert.ThrowsExactly(() => input.SplitToBatch(2).ToList());
}
[TestMethod]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
public void SplitToBatch_BatchSizeZero_ThrowsArgumentOutOfRangeException()
{
var input = Enumerable.Range(1, 3);
- _ = input.SplitToBatch(0).ToList();
+ Assert.ThrowsExactly(() => input.SplitToBatch(0).ToList());
}
[TestMethod]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
public void SplitToBatch_BatchSizeNegative_ThrowsArgumentOutOfRangeException()
{
var input = Enumerable.Range(1, 3);
- _ = input.SplitToBatch(-1).ToList();
+ Assert.ThrowsExactly(() => input.SplitToBatch(-1).ToList());
}
}
\ No newline at end of file
diff --git a/tests/LuYao.Common.UnitTests/Collections/Generic/KeyedListTests.cs b/tests/LuYao.Common.UnitTests/Collections/Generic/KeyedListTests.cs
index 3611bef..8754b09 100644
--- a/tests/LuYao.Common.UnitTests/Collections/Generic/KeyedListTests.cs
+++ b/tests/LuYao.Common.UnitTests/Collections/Generic/KeyedListTests.cs
@@ -63,13 +63,20 @@ public void Constructor_WithValidKeySelector_CreatesInstance()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentNullException))]
+
+
public void Constructor_WithNullKeySelector_ThrowsArgumentNullException()
+
+
{
- // Arrange & Act
- var keyedList = new KeyedList(null!);
- // Assert: 期望抛出 ArgumentNullException
+
+ // Arrange, Act & Assert
+
+
+ Assert.ThrowsExactly(() => new KeyedList(null!));
+
+
}
#endregion
@@ -87,13 +94,20 @@ public void Indexer_GetWithValidIndex_ReturnsCorrectItem()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
+
+
public void Indexer_GetWithInvalidIndex_ThrowsArgumentOutOfRangeException()
+
+
{
- // Arrange & Act
- var item = _keyedList[-1];
- // Assert: 期望抛出 ArgumentOutOfRangeException
+
+ // Arrange, Act & Assert
+
+
+ Assert.ThrowsExactly(() => _keyedList[-1]);
+
+
}
[TestMethod]
@@ -110,16 +124,27 @@ public void Indexer_SetWithValidIndex_UpdatesItem()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
+
+
public void Indexer_SetWithInvalidIndex_ThrowsArgumentOutOfRangeException()
+
+
{
+
+
// Arrange
+
+
var newItem = new TestItem { Id = 10, Name = "New Item" };
- // Act
- _keyedList[10] = newItem;
- // Assert: 期望抛出 ArgumentOutOfRangeException
+
+ // Act & Assert
+
+
+ Assert.ThrowsExactly(() => _keyedList[10] = newItem);
+
+
}
#endregion
@@ -375,39 +400,30 @@ public void CopyTo_ValidArrayWithOffset_CopiesItemsWithOffset()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentNullException))]
public void CopyTo_NullArray_ThrowsArgumentNullException()
{
- // Arrange & Act
- _keyedList.CopyTo(null!, 0);
-
- // Assert: 期望抛出 ArgumentNullException
+ // Arrange, Act & Assert
+ Assert.ThrowsExactly(() => _keyedList.CopyTo(null!, 0));
}
[TestMethod]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
public void CopyTo_NegativeArrayIndex_ThrowsArgumentOutOfRangeException()
{
// Arrange
var array = new TestItem[_keyedList.Count];
- // Act
- _keyedList.CopyTo(array, -1);
-
- // Assert: 期望抛出 ArgumentOutOfRangeException
+ // Act & Assert
+ Assert.ThrowsExactly(() => _keyedList.CopyTo(array, -1));
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void CopyTo_InsufficientArraySpace_ThrowsArgumentException()
{
// Arrange
var array = new TestItem[_keyedList.Count - 1];
- // Act
- _keyedList.CopyTo(array, 0);
-
- // Assert: 期望抛出 ArgumentException
+ // Act & Assert
+ Assert.ThrowsExactly(() => _keyedList.CopyTo(array, 0));
}
#endregion
@@ -482,29 +498,23 @@ public void Insert_ValidIndex_InsertsItemAtCorrectPosition()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
public void Insert_NegativeIndex_ThrowsArgumentOutOfRangeException()
{
// Arrange
var newItem = new TestItem { Id = 4, Name = "Item 4" };
- // Act
- _keyedList.Insert(-1, newItem);
-
- // Assert: 期望抛出 ArgumentOutOfRangeException
+ // Act & Assert
+ Assert.ThrowsExactly(() => _keyedList.Insert(-1, newItem));
}
[TestMethod]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
public void Insert_IndexGreaterThanCount_ThrowsArgumentOutOfRangeException()
{
// Arrange
var newItem = new TestItem { Id = 4, Name = "Item 4" };
- // Act
- _keyedList.Insert(_keyedList.Count + 1, newItem);
-
- // Assert: 期望抛出 ArgumentOutOfRangeException
+ // Act & Assert
+ Assert.ThrowsExactly(() => _keyedList.Insert(_keyedList.Count + 1, newItem));
}
#endregion
@@ -562,23 +572,17 @@ public void RemoveAt_ValidIndex_RemovesItemAtIndex()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
public void RemoveAt_NegativeIndex_ThrowsArgumentOutOfRangeException()
{
- // Act
- _keyedList.RemoveAt(-1);
-
- // Assert: 期望抛出 ArgumentOutOfRangeException
+ // Act & Assert
+ Assert.ThrowsExactly(() => _keyedList.RemoveAt(-1));
}
[TestMethod]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
public void RemoveAt_IndexEqualToCount_ThrowsArgumentOutOfRangeException()
{
- // Act
- _keyedList.RemoveAt(_keyedList.Count);
-
- // Assert: 期望抛出 ArgumentOutOfRangeException
+ // Act & Assert
+ Assert.ThrowsExactly(() => _keyedList.RemoveAt(_keyedList.Count));
}
#endregion
diff --git a/tests/LuYao.Common.UnitTests/Collections/Generic/WeakCollectionTests.cs b/tests/LuYao.Common.UnitTests/Collections/Generic/WeakCollectionTests.cs
index 3420e20..1154fa6 100644
--- a/tests/LuYao.Common.UnitTests/Collections/Generic/WeakCollectionTests.cs
+++ b/tests/LuYao.Common.UnitTests/Collections/Generic/WeakCollectionTests.cs
@@ -16,7 +16,7 @@ public void Add_NullItem_ThrowsArgumentNullException()
var collection = new WeakCollection