Skip to content

Commit f71cd1a

Browse files
committed
Improved codegen, moved throw code to external method
Also added a more detailed exception message for users
1 parent be11d53 commit f71cd1a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Microsoft.Toolkit/Collections/ReadOnlyObservableGroupedCollection.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,16 @@ private void OnSourceCollectionChanged(object sender, NotifyCollectionChangedEve
5252
// reporting the changes one by one. We consider only this case for now.
5353
if (e.OldItems?.Count > 1 || e.NewItems?.Count > 1)
5454
{
55-
Debug.Fail("OldItems and NewItems should contain at most 1 item");
56-
throw new NotSupportedException();
55+
static void ThrowNotSupportedException()
56+
{
57+
throw new NotSupportedException(
58+
"ReadOnlyObservableGroupedCollection<TKey, TValue> doesn't support operations on multiple items at once.\n" +
59+
"If this exception was thrown, it likely means support for batched item updates has been added to the " +
60+
"underlying ObservableCollection<T> type, and this implementation doesn't support that feature yet.\n" +
61+
"Please consider opening an issue in https://github.com/windows-toolkit/WindowsCommunityToolkit to report this.");
62+
}
63+
64+
ThrowNotSupportedException();
5765
}
5866

5967
var newItem = e.NewItems?.Cast<ObservableGroup<TKey, TValue>>()?.FirstOrDefault();

0 commit comments

Comments
 (0)