{"record":{"id":"1830d9df77667b7d","repo":"AvaloniaUI/Avalonia","slug":"collection-reset-not-supported","errorCode":null,"errorMessage":"Collection reset not supported.","messagePattern":"Collection reset not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Collections/AvaloniaListExtensions.cs","lineNumber":197,"sourceCode":"                    var inpc = x as INotifyPropertyChanged;\n\n                    if (inpc != null)\n                    {\n                        inpc.PropertyChanged += handler;\n                        tracked.Add(inpc);\n                    }\n                },\n                x =>\n                {\n                    var inpc = x as INotifyPropertyChanged;\n\n                    if (inpc != null)\n                    {\n                        inpc.PropertyChanged -= handler;\n                        tracked.Remove(inpc);\n                    }\n                },\n                () => throw new NotSupportedException(\"Collection reset not supported.\"));\n\n            return Disposable.Create(() =>\n            {\n                foreach (var i in tracked)\n                {\n                    i.PropertyChanged -= handler;\n                }\n            });\n        }\n    }\n}\n","sourceCodeStart":179,"sourceCodeEnd":209,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Collections/AvaloniaListExtensions.cs#L179-L209","documentation":"NotSupportedException ('Collection reset not supported.') thrown by AvaloniaListExtensions.TrackItemPropertyChanged when the observed collection raises a Reset event. By design TrackItemPropertyChanged wires a throwing delegate as the reset handler because it cannot safely re-subscribe property-changed handlers after a wholesale reset, so resets are explicitly unsupported.","triggerScenarios":"Calling collection.TrackItemPropertyChanged(callback) on a list that subsequently raises NotifyCollectionChangedAction.Reset (Clear, reload, filter change).","commonSituations":"Tracking PropertyChanged on items in a collection that gets cleared or rebuilt (data refresh, navigation, filtering); ObservableCollection<T>.Clear() which raises Reset.","solutions":["Avoid Reset on the tracked collection — remove items individually instead of calling Clear().","Dispose the TrackItemPropertyChanged subscription before reloading and re-create it afterward.","Replace wholesale Clear() with a Remove-based teardown so Reset is never raised."],"exampleFix":"// before\nusing var sub = items.TrackItemPropertyChanged(OnItemChanged);\nitems.Clear(); // raises Reset -> throws\n\n// after\nsub.Dispose();\nitems.Clear();\nusing var sub2 = items.TrackItemPropertyChanged(OnItemChanged);","handlingStrategy":"validation","validationCode":"sub.Dispose();\ncollection.Clear();\nsub = collection.TrackItemPropertyChanged(callback);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never Clear() a collection tracked by TrackItemPropertyChanged; dispose first.","Remove items individually instead of resetting.","Re-create the subscription after a reload."],"tags":["avalonia","collections","list","reactive","not-supported","collection-changed"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}