{"record":{"id":"4f135d2bea4c3ad4","repo":"stride3d/stride","slug":"cannot-change-the-name-of-a-entityhierarchyrootviewmodel","errorCode":null,"errorMessage":"Cannot change the name of a EntityHierarchyRootViewModel object.","messagePattern":"Cannot change the name of a EntityHierarchyRootViewModel object\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/ViewModels/EntityHierarchyRootViewModel.cs","lineNumber":43,"sourceCode":"            : base(editor, asset, asset.Asset.Hierarchy.EnumerateRootPartDesigns(), null)\n        {\n            this.name = name ?? throw new ArgumentNullException(nameof(name));\n            rootEntitiesNode = Editor.Session.AssetNodeContainer.GetNode(EntityHierarchy.Hierarchy)[nameof(AssetCompositeHierarchyData<EntityDesign, Entity>.RootParts)].Target;\n            rootEntitiesNode.ItemChanging += RootEntitiesChanging;\n            rootEntitiesNode.ItemChanged += RootEntitiesChanged;\n            entitiesNode = Editor.Session.AssetNodeContainer.GetNode(EntityHierarchy.Hierarchy)[nameof(AssetCompositeHierarchyData<EntityDesign, Entity>.Parts)].Target;\n            entitiesNode.ItemChanged += EntitiesChanged;\n        }\n\n        /// <inheritdoc/>\n        public override IEnumerable<EntityViewModel> InnerSubEntities => Children.SelectMany(x => x.InnerSubEntities);\n\n        /// <inheritdoc />\n        public override bool IsEditable => false;\n\n        /// <inheritdoc/>\n        [NotNull]\n        public override string Name { get => name; set => throw new NotSupportedException($\"Cannot change the name of a {nameof(EntityHierarchyRootViewModel)} object.\"); }\n\n        /// <inheritdoc/>\n        internal override int EntityCount => EntityHierarchy.Hierarchy.RootParts.Count;\n\n        /// <inheritdoc/>\n        public override void Destroy()\n        {\n            EnsureNotDestroyed(nameof(EntityHierarchyRootViewModel));\n            rootEntitiesNode.ItemChanging -= RootEntitiesChanging;\n            rootEntitiesNode.ItemChanged -= RootEntitiesChanged;\n            entitiesNode.ItemChanged -= EntitiesChanged;\n\n            base.Destroy();\n        }\n\n        /// <inheritdoc/>\n        public override GraphNodePath GetNodePath()\n        {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/ViewModels/EntityHierarchyRootViewModel.cs#L25-L61","documentation":"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.","triggerScenarios":"Assigning to the Name property of an EntityHierarchyRootViewModel, whether via code (root.Name = \"x\") or a two-way UI binding on the root node.","commonSituations":"Generic property-grid or rename UI applied to all hierarchy nodes including the root; scripts that iterate nodes renaming them without checking IsEditable.","solutions":["Don't rename the hierarchy root; rename only entity/folder nodes","Check node.IsEditable before attempting to set Name","Skip EntityHierarchyRootViewModel instances in rename loops"],"exampleFix":"// before\nnode.Name = newName; // throws for root node\n// after\nif (node.IsEditable)\n    node.Name = newName;","handlingStrategy":"type-guard","validationCode":"if (node.IsEditable)\n    node.Name = newName;","typeGuard":"bool IsRenamable(INodeViewModel node) => node is not EntityHierarchyRootViewModel && node.IsEditable;","tryCatchPattern":"try { node.Name = newName; }\ncatch (NotSupportedException) { /* root node name is immutable */ }","preventionTips":["Check IsEditable before any rename","Skip root view-models in bulk rename operations","Use read-only bindings for root node name in UI"],"tags":["csharp","stride","read-only","viewmodel"],"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"}