{"record":{"id":"86072f6ef17256aa","repo":"stride3d/stride","slug":"reset-is-not-supported-by-the-asset-tracker","errorCode":null,"errorMessage":"Reset is not supported by the asset tracker.","messagePattern":"Reset is not supported by the asset tracker\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/AssetTracker.cs","lineNumber":162,"sourceCode":"\n    private void Assets_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)\n    {\n        switch (e.Action)\n        {\n            case NotifyCollectionChangedAction.Add:\n                foreach (var assetItem in e.NewItems?.OfType<AssetItem>() ?? [])\n                {\n                    TrackAsset(assetItem);\n                }\n                break;\n            case NotifyCollectionChangedAction.Remove:\n                foreach (var assetItem in e.OldItems?.OfType<AssetItem>() ?? [])\n                {\n                    UnTrackAsset(assetItem);\n                }\n                break;\n            default:\n                throw new NotSupportedException(\"Reset is not supported by the asset tracker.\");\n        }\n    }\n}\n","sourceCodeStart":144,"sourceCodeEnd":166,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/AssetTracker.cs#L144-L166","documentation":"AssetTracker.Assets_CollectionChanged throws NotSupportedException when the collection-changed action is Reset. The tracker processes Add/Remove notifications incrementally (TrackAsset/UnTrackAsset) and cannot reconstruct its state from a reset event, so it refuses.","triggerScenarios":"Raising NotifyCollectionChangedAction.Reset on the tracked asset collection while an AssetTracker is subscribed — e.g. Clear() implementations that fire Reset instead of per-item Remove events.","commonSituations":"Bulk-clearing an AssetCollection whose implementation signals Reset; reassigning the collection's contents in one operation while tracking is active.","solutions":["Unsubscribe/dispose the AssetTracker before performing the Reset, then re-track afterwards.","Replace Clear() with per-item Remove calls so the tracker sees Add/Remove events.","Re-create the tracker after the reset so it starts from a clean snapshot."],"exampleFix":"// before\nassetCollection.Clear(); // raises Reset -> tracker throws\n// after\nforeach (var item in assetCollection.ToList()) assetCollection.Remove(item);","handlingStrategy":"try-catch","validationCode":"if (e.Action == NotifyCollectionChangedAction.Reset) tracker.Dispose(); // detach before reset","typeGuard":null,"tryCatchPattern":"try { assets.Clear(); } catch (NotSupportedException ex) when (ex.Message.Contains(\"Reset is not supported\")) { // untrack, clear, recreate tracker\ntracker.Dispose(); assets.Clear(); tracker = new AssetTracker(...); }","preventionTips":["Avoid collections that signal Reset for tracked asset collections.","Implement Clear() as per-item Remove events.","Dispose trackers before bulk mutations and re-create afterwards."],"tags":["assets","tracking","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}