diff --git a/MoreLinq/Collections/Dictionary.cs b/MoreLinq/Collections/Dictionary.cs index 4241ae650..fad4e1a03 100644 --- a/MoreLinq/Collections/Dictionary.cs +++ b/MoreLinq/Collections/Dictionary.cs @@ -29,12 +29,12 @@ namespace MoreLinq.Collections // Add members if and when needed to keep coverage. - struct Dictionary + sealed class Dictionary { readonly System.Collections.Generic.Dictionary _dict; (bool, TValue) _null; - public Dictionary(IEqualityComparer comparer) : this() + public Dictionary(IEqualityComparer comparer) { _dict = new System.Collections.Generic.Dictionary(comparer); _null = default; @@ -44,8 +44,6 @@ public TValue this[TKey key] { set { - DefaultGuard(); - if (key is null) _null = (true, value); else @@ -55,8 +53,6 @@ public TValue this[TKey key] public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) { - DefaultGuard(); - if (key is null) { switch (_null) @@ -72,11 +68,5 @@ public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) return _dict.TryGetValue(key, out value); } - - void DefaultGuard() - { - if (_dict is null) - throw new InvalidOperationException(); - } } }