stride3d/stride · error · ArgumentException
Reset is not supported by the undo stack.
Error message
Reset is not supported by the undo stack.
What it means
CollectionChangeOperation records undoable list changes for the undo stack. The private constructor validates a NotifyCollectionChangedAction and explicitly rejects Reset, which carries no per-item information to invert.
Solutions
- Avoid Clear()/Reset-style operations on collections tracked by the undo stack; remove items individually so Add/Remove operations are recorded
- Handle Reset separately in code that translates collection-changed events into undo operations
- Clear the undo stack intentionally before performing the reset
Example fix
// before list.Clear(); // produces Reset, unsupported by undo // after while (list.Count > 0) list.RemoveAt(list.Count - 1); // per-item undoable removals
Defensive patterns
Strategy: validation
Validate before calling
if (args.Action == NotifyCollectionChangedAction.Reset) { /* clear undo stack instead of recording */ return; } Type guard
bool IsUndoableAction(NotifyCollectionChangedAction a) => a is NotifyCollectionChangedAction.Add or NotifyCollectionChangedAction.Remove or NotifyCollectionChangedAction.Replace;
Try / catch
try { op = CreateCollectionChangeOperation(list, action, dirtiables); } catch (ArgumentException) { undoStack.Clear(); } Prevention
- Avoid Clear()/Reset on undo-tracked lists
- Remove items individually for undoable clears
- Pre-filter Reset notifications before recording
When it happens
Trigger: Constructing a CollectionChangeOperation (via internal factories handling collection changes) where actionToUndo equals NotifyCollectionChangedAction.Reset, e.g. a Clear() or a bulk reset on an observed list wrapped by the dirtiables/undo system.
Common situations: Clearing a bound collection that participates in undo/redo; replacing a collection's contents wholesale so the framework sees a Reset event.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Move is not supported by the undo stack.
- An element with the same key has already been added.
- An item with the same key has already been added.
- An item with the same key has already been added.
- Array is null
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b9776c48d5486eb8.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation/Dirtiables/CollectionChangeOperation.cs:19
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System.Collections;
using System.Collections.Specialized;
namespace Stride.Core.Presentation.Dirtiables;
public class CollectionChangeOperation : DirtyingOperation
{
private readonly int index;
private IList? list;
private IReadOnlyCollection<object>? items;
private CollectionChangeOperation(IList list, NotifyCollectionChangedAction actionToUndo, IEnumerable<IDirtiable> dirtiables)
: base(dirtiables)
{
ArgumentNullException.ThrowIfNull(list);
if (actionToUndo == NotifyCollectionChangedAction.Reset) throw new ArgumentException("Reset is not supported by the undo stack.");
ActionToUndo = actionToUndo;
this.list = list;
}
public CollectionChangeOperation(IList list, NotifyCollectionChangedAction actionToUndo, IReadOnlyCollection<object> items, int index, IEnumerable<IDirtiable> dirtiables)
: this(list, actionToUndo, dirtiables)
{
ArgumentNullException.ThrowIfNull(items);
this.items = items;
this.index = index;
}
public CollectionChangeOperation(IList list, NotifyCollectionChangedEventArgs args, IEnumerable<IDirtiable> dirtiables)
: this(list, args.Action, dirtiables)
{
switch (args.Action)View on GitHub (pinned to 96fad776d2)