{"record":{"id":"4ad198bbb57fa0e4","repo":"stride3d/stride","slug":"replace-move-and-reset-are-not-supported-on-this-collection","errorCode":null,"errorMessage":"Replace, Move and Reset are not supported on this collection.","messagePattern":"Replace, Move and Reset are not supported on this collection\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/ViewModels/EntityHierarchyItemViewModel.cs","lineNumber":375,"sourceCode":"                            AddItem(newItem);\n                        else\n                            InsertItem(addIndex++, newItem);\n                    }\n                    break;\n                case NotifyCollectionChangedAction.Remove:\n                    var delIndex = offset + e.OldStartingIndex;\n                    foreach (EntityHierarchyItemViewModel oldItem in e.OldItems)\n                    {\n                        if (e.OldStartingIndex < 0)\n                            RemoveItem(oldItem);\n                        else\n                            RemoveItemAt(delIndex);\n                    }\n                    break;\n                case NotifyCollectionChangedAction.Replace:\n                case NotifyCollectionChangedAction.Move:\n                case NotifyCollectionChangedAction.Reset:\n                    throw new NotSupportedException(\"Replace, Move and Reset are not supported on this collection.\");\n                default:\n                    throw new ArgumentOutOfRangeException();\n            }\n        }\n\n        /// <summary>\n        /// Gets how this item accepts the given children.\n        /// </summary>\n        /// <param name=\"children\">The children to add or to insert.</param>\n        /// <param name=\"checkSameParent\">True to give a no-op when a child is already a child of this item.</param>\n        /// <param name=\"modifiers\">The modifier keys currently active.</param>\n        /// <param name=\"index\">The index at which the children go.</param>\n        /// <param name=\"message\">The feedback message that can be used in the user interface.</param>\n        /// <remarks>\n        /// A rejected child stops the check immediately. If no child is rejected and no child is accepted, but a child\n        /// changes nothing, the result is <see cref=\"DropAcceptance.NoOp\"/>. Therefore a selection that mixes items\n        /// which are already here with items which are not stays accepted, and it moves only the second group.\n        /// </remarks>","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/ViewModels/EntityHierarchyItemViewModel.cs#L357-L393","documentation":"EntityHierarchyItemViewModel.SubEntityCollectionChanged handles Add and Remove collection-change notifications only; Replace, Move and Reset are explicitly not supported by this view-model collection, and NotSupportedException is thrown. The underlying entity hierarchy never produces those actions by design.","triggerScenarios":"Raising a CollectionChanged event with Replace, Move, or Reset actions on the sub-entities collection, typically from custom code that manipulates the collection directly with ObservableCollection APIs like Move() or Clear() with Reset semantics.","commonSituations":"Custom tooling that calls collection.Move() or resets the collection; binding layers that trigger Reset notifications; replacing an entity in place instead of removing and re-adding it.","solutions":["Express Replace as Remove followed by Add","Express Move as Remove then Add at the target index (or use dedicated editor reorder APIs)","Avoid Clear()/Reset; remove items individually so Remove notifications are raised"],"exampleFix":"// before\nsubEntities.Move(2, 0); // triggers Move notification -> throws\n// after\nvar item = subEntities[2];\nsubEntities.RemoveAt(2);\nsubEntities.Insert(0, item);","handlingStrategy":"try-catch","validationCode":"// express batch edits as Add/Remove only\nforeach (var item in itemsToRemove) subEntities.Remove(item);","typeGuard":null,"tryCatchPattern":"try { collectionMoveLogic(); }\ncatch (NotSupportedException) { /* fall back to remove+insert */ }","preventionTips":["Avoid ObservableCollection.Move and Clear on sub-entity collections","Simulate Replace/Move with Remove+Add pairs","Use the editor's transaction APIs for reordering"],"tags":["csharp","stride","collection","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"}