stride3d/stride · error · NotSupportedException

Cannot change the name of a EntityHierarchyRootViewModel…

Error message

Cannot change the name of a EntityHierarchyRootViewModel object.

What it means

EntityHierarchyRootViewModel represents the immutable root of the entity hierarchy and overrides Name's setter to always throw NotSupportedException. Its IsEditable is false, signaling the name should never be changed by users or code.

Solutions

  1. Don't rename the hierarchy root; rename only entity/folder nodes
  2. Check node.IsEditable before attempting to set Name
  3. Skip EntityHierarchyRootViewModel instances in rename loops

Example fix

// before
node.Name = newName; // throws for root node
// after
if (node.IsEditable)
    node.Name = newName;
Defensive patterns

Strategy: type-guard

Validate before calling

if (node.IsEditable)
    node.Name = newName;

Type guard

bool IsRenamable(INodeViewModel node) => node is not EntityHierarchyRootViewModel && node.IsEditable;

Try / catch

try { node.Name = newName; }
catch (NotSupportedException) { /* root node name is immutable */ }

Prevention

When it happens

Trigger: Assigning to the Name property of an EntityHierarchyRootViewModel, whether via code (root.Name = "x") or a two-way UI binding on the root node.

Common situations: Generic property-grid or rename UI applied to all hierarchy nodes including the root; scripts that iterate nodes renaming them without checking IsEditable.

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


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

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/ViewModels/EntityHierarchyRootViewModel.cs:43

            : base(editor, asset, asset.Asset.Hierarchy.EnumerateRootPartDesigns(), null)
        {
            this.name = name ?? throw new ArgumentNullException(nameof(name));
            rootEntitiesNode = Editor.Session.AssetNodeContainer.GetNode(EntityHierarchy.Hierarchy)[nameof(AssetCompositeHierarchyData<EntityDesign, Entity>.RootParts)].Target;
            rootEntitiesNode.ItemChanging += RootEntitiesChanging;
            rootEntitiesNode.ItemChanged += RootEntitiesChanged;
            entitiesNode = Editor.Session.AssetNodeContainer.GetNode(EntityHierarchy.Hierarchy)[nameof(AssetCompositeHierarchyData<EntityDesign, Entity>.Parts)].Target;
            entitiesNode.ItemChanged += EntitiesChanged;
        }

        /// <inheritdoc/>
        public override IEnumerable<EntityViewModel> InnerSubEntities => Children.SelectMany(x => x.InnerSubEntities);

        /// <inheritdoc />
        public override bool IsEditable => false;

        /// <inheritdoc/>
        [NotNull]
        public override string Name { get => name; set => throw new NotSupportedException($"Cannot change the name of a {nameof(EntityHierarchyRootViewModel)} object."); }

        /// <inheritdoc/>
        internal override int EntityCount => EntityHierarchy.Hierarchy.RootParts.Count;

        /// <inheritdoc/>
        public override void Destroy()
        {
            EnsureNotDestroyed(nameof(EntityHierarchyRootViewModel));
            rootEntitiesNode.ItemChanging -= RootEntitiesChanging;
            rootEntitiesNode.ItemChanged -= RootEntitiesChanged;
            entitiesNode.ItemChanged -= EntitiesChanged;

            base.Destroy();
        }

        /// <inheritdoc/>
        public override GraphNodePath GetNodePath()
        {

View on GitHub (pinned to 96fad776d2)