diff --git a/Microsoft.Toolkit/Collections/ObservableGroupedCollectionExtensions.cs b/Microsoft.Toolkit/Collections/ObservableGroupedCollectionExtensions.cs index 69e17bbc085..b52d778f560 100644 --- a/Microsoft.Toolkit/Collections/ObservableGroupedCollectionExtensions.cs +++ b/Microsoft.Toolkit/Collections/ObservableGroupedCollectionExtensions.cs @@ -444,7 +444,6 @@ private static void RemoveItemAtWithLinq( /// /// Throws a new when a key is not found. /// - [MethodImpl(MethodImplOptions.NoInlining)] private static void ThrowArgumentExceptionForKeyNotFound() { throw new InvalidOperationException("The requested key was not present in the collection"); diff --git a/Microsoft.Toolkit/Collections/ReadOnlyObservableGroupedCollection.cs b/Microsoft.Toolkit/Collections/ReadOnlyObservableGroupedCollection.cs index 9ff14698586..42d012356f7 100644 --- a/Microsoft.Toolkit/Collections/ReadOnlyObservableGroupedCollection.cs +++ b/Microsoft.Toolkit/Collections/ReadOnlyObservableGroupedCollection.cs @@ -52,8 +52,16 @@ private void OnSourceCollectionChanged(object sender, NotifyCollectionChangedEve // reporting the changes one by one. We consider only this case for now. if (e.OldItems?.Count > 1 || e.NewItems?.Count > 1) { - Debug.Fail("OldItems and NewItems should contain at most 1 item"); - throw new NotSupportedException(); + static void ThrowNotSupportedException() + { + throw new NotSupportedException( + "ReadOnlyObservableGroupedCollection doesn't support operations on multiple items at once.\n" + + "If this exception was thrown, it likely means support for batched item updates has been added to the " + + "underlying ObservableCollection type, and this implementation doesn't support that feature yet.\n" + + "Please consider opening an issue in https://aka.ms/windowstoolkit to report this."); + } + + ThrowNotSupportedException(); } var newItem = e.NewItems?.Cast>()?.FirstOrDefault();