diff --git a/GFramework.Core.Tests/Events/EasyEventsTests.cs b/GFramework.Core.Tests/Events/EasyEventsTests.cs
index 404fe024..2b83ff08 100644
--- a/GFramework.Core.Tests/Events/EasyEventsTests.cs
+++ b/GFramework.Core.Tests/Events/EasyEventsTests.cs
@@ -99,14 +99,14 @@ public class EasyEventsTests
}
///
- /// 测试并发场景下AddEvent的行为
+ /// 测试 AddEvent 对重复事件类型给出状态冲突异常。
///
[Test]
public void AddEvent_Should_Throw_When_Already_Registered()
{
_easyEvents.AddEvent>();
- Assert.Throws(() => _easyEvents.AddEvent>());
+ Assert.Throws(() => _easyEvents.AddEvent>());
}
///
@@ -167,4 +167,4 @@ public class EasyEventsTests
Assert.That(_easyEvents.GetEvent>(), Is.Not.Null);
Assert.That(_easyEvents.GetEvent>(), Is.Not.Null);
}
-}
\ No newline at end of file
+}
diff --git a/GFramework.Core/Coroutine/CoroutineScheduler.cs b/GFramework.Core/Coroutine/CoroutineScheduler.cs
index ed57b06f..a7fb8676 100644
--- a/GFramework.Core/Coroutine/CoroutineScheduler.cs
+++ b/GFramework.Core/Coroutine/CoroutineScheduler.cs
@@ -41,7 +41,7 @@ public sealed class CoroutineScheduler(
private readonly Dictionary _completionStatuses = new();
private readonly Queue _completionStatusOrder = new();
- private readonly Dictionary> _grouped = new();
+ private readonly Dictionary> _grouped = new(StringComparer.Ordinal);
private readonly ILogger _logger = LoggerFactoryResolver.Provider.CreateLogger(nameof(CoroutineScheduler));
private readonly Dictionary _metadata = new();
private readonly ConcurrentQueue _pendingKills = new();
@@ -50,7 +50,7 @@ public sealed class CoroutineScheduler(
throw new ArgumentNullException(nameof(timeSource));
private readonly CoroutineStatistics? _statistics = enableStatistics ? new CoroutineStatistics() : null;
- private readonly Dictionary> _tagged = new();
+ private readonly Dictionary> _tagged = new(StringComparer.Ordinal);
private readonly ITimeSource _timeSource = timeSource ?? throw new ArgumentNullException(nameof(timeSource));
private readonly Dictionary> _waiting = new();
private int _nextSlot;
diff --git a/GFramework.Core/Events/EasyEvents.cs b/GFramework.Core/Events/EasyEvents.cs
index 5159944e..adf42898 100644
--- a/GFramework.Core/Events/EasyEvents.cs
+++ b/GFramework.Core/Events/EasyEvents.cs
@@ -53,12 +53,12 @@ public class EasyEvents
/// 添加指定类型的事件到事件字典中
///
/// 事件类型,必须实现IEasyEvent接口且具有无参构造函数
- /// 当事件类型已存在时抛出
+ /// 当事件类型已存在时抛出。
public void AddEvent() where T : IEvent, new()
{
if (!_mTypeEvents.TryAdd(typeof(T), new T()))
{
- throw new ArgumentException($"Event type {typeof(T).Name} already registered.");
+ throw new InvalidOperationException($"Event type {typeof(T).Name} already registered.");
}
}
@@ -81,4 +81,4 @@ public class EasyEvents
{
return (T)_mTypeEvents.GetOrAdd(typeof(T), _ => new T());
}
-}
\ No newline at end of file
+}
diff --git a/GFramework.Core/Extensions/CollectionExtensions.cs b/GFramework.Core/Extensions/CollectionExtensions.cs
index 849f3ae5..19d02671 100644
--- a/GFramework.Core/Extensions/CollectionExtensions.cs
+++ b/GFramework.Core/Extensions/CollectionExtensions.cs
@@ -81,7 +81,7 @@ public static class CollectionExtensions
/// // dict["a"] == 3 (最后一个值)
///
///
- public static Dictionary ToDictionarySafe(
+ public static IDictionary ToDictionarySafe(
this IEnumerable source,
Func keySelector,
Func valueSelector) where TKey : notnull
diff --git a/GFramework.Core/Functional/Option.cs b/GFramework.Core/Functional/Option.cs
index 709c3438..31d18d2e 100644
--- a/GFramework.Core/Functional/Option.cs
+++ b/GFramework.Core/Functional/Option.cs
@@ -17,7 +17,7 @@ namespace GFramework.Core.Functional;
/// 表示可能存在或不存在的值,用于替代 null 引用的函数式编程类型
///
/// 值的类型
-public readonly struct Option
+public readonly struct Option : IEquatable