diff --git a/Microsoft.Toolkit.Mvvm/Messaging/Microsoft.Collections.Extensions/DictionarySlim{TKey,TValue}.cs b/Microsoft.Toolkit.Mvvm/Messaging/Microsoft.Collections.Extensions/DictionarySlim{TKey,TValue}.cs index 7597d309..a65bf440 100644 --- a/Microsoft.Toolkit.Mvvm/Messaging/Microsoft.Collections.Extensions/DictionarySlim{TKey,TValue}.cs +++ b/Microsoft.Toolkit.Mvvm/Messaging/Microsoft.Collections.Extensions/DictionarySlim{TKey,TValue}.cs @@ -243,7 +243,7 @@ namespace Microsoft.Collections.Extensions if ((uint)newSize > int.MaxValue) { - throw new InvalidOperationException("Max capacity exceeded"); + ThrowInvalidOperationExceptionForMaxCapacityExceeded(); } var entries = new Entry[newSize]; @@ -328,5 +328,14 @@ namespace Microsoft.Collections.Extensions { throw new ArgumentException($"The target key {key} was not present in the dictionary"); } + + /// + /// Throws an when trying to resize over the maximum capacity. + /// + [MethodImpl(MethodImplOptions.NoInlining)] + private static void ThrowInvalidOperationExceptionForMaxCapacityExceeded() + { + throw new InvalidOperationException("Max capacity exceeded"); + } } } \ No newline at end of file