stride3d/stride · error · ArgumentException

The action must be FolderRenamed when using this…

Error message

The action must be FolderRenamed when using this constructor.

What it means

This EntityFolderOperation constructor overload is intended exclusively for folder rename operations; it stores an oldFolderName which only makes sense for renames. Passing any other Action value throws ArgumentException naming the action parameter.

Solutions

  1. Use Action.FolderRenamed with this constructor
  2. For FolderCreated/FolderDeleted use the 4-argument overload without oldFolderName
  3. Refactor operation creation to dispatch on the action enum and select the matching constructor

Example fix

// before
new EntityFolderOperation(asset, Action.FolderCreated, path, oldName, ownerId); // throws
// after
new EntityFolderOperation(asset, Action.FolderRenamed, path, oldName, ownerId);
Defensive patterns

Strategy: validation

Validate before calling

if (action != EntityFolderOperation.Action.FolderRenamed)
    throw new ArgumentException("Use the FolderRenamed ctor only for renames", nameof(action));

Try / catch

try { op = new EntityFolderOperation(asset, action, path, oldName, ownerId); }
catch (ArgumentException ex) { log.Error(ex); op = null; }

Prevention

When it happens

Trigger: Constructing EntityFolderOperation with the 5-argument overload (asset, action, folderPath, oldFolderName, ownerId) while action is FolderCreated or FolderDeleted instead of FolderRenamed.

Common situations: Copy-pasted undo/redo operation construction; switching Action enums without switching constructor overload; generic operation builders that pick the wrong ctor for the action.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/cad5112e80d1d1a5. Report an issue: GitHub.

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/ViewModels/EntityFolderOperation.cs:38

    {
        private readonly AbsoluteId ownerId;
        private readonly string[] folderPath;
        private Action action;
        private string oldFolderName;
        private EntityHierarchyViewModel asset;

        public enum Action
        {
            FolderCreated,
            FolderDeleted,
            FolderRenamed,
        }

        public EntityFolderOperation([NotNull] EntityHierarchyViewModel asset, Action action, [NotNull] string folderPath, string oldFolderName, AbsoluteId ownerId)
            : this(action, folderPath, ownerId, asset.SafeArgument(nameof(asset)).Dirtiables)
        {
            if (action != Action.FolderRenamed)
                throw new ArgumentException(@"The action must be FolderRenamed when using this constructor.", nameof(action));

            this.asset = asset;
            this.oldFolderName = oldFolderName;
        }

        public EntityFolderOperation([NotNull] EntityHierarchyViewModel asset, Action action, [NotNull] string folderPath, AbsoluteId ownerId)
            : this(action, folderPath, ownerId, asset.SafeArgument(nameof(asset)).Dirtiables)
        {
            if (action != Action.FolderCreated && action != Action.FolderDeleted)
                throw new ArgumentException(@"The action must be FolderCreated or FolderDeleted when using this constructor.", nameof(action));

            this.asset = asset;
        }

        private EntityFolderOperation(Action action, [NotNull] string folderPath, AbsoluteId ownerId, IEnumerable<IDirtiable> dirtiables)
            : base(dirtiables)
        {
            this.action = action;

View on GitHub (pinned to 96fad776d2)