{"record":{"id":"28cb7d1c3846526e","repo":"stride3d/stride","slug":"cannot-change-the-name-of-a-nameof-scenerootviewmodel-object","errorCode":null,"errorMessage":"Cannot change the name of a {nameof(SceneRootViewModel)} object.","messagePattern":"Cannot change the name of a (.+?) object\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/SceneEditor/ViewModels/SceneRootViewModel.cs","lineNumber":69,"sourceCode":"            scene.Children.CollectionChanged += SceneChildrenCollectionChanged;\n\n            var offsetNode = Editor.NodeContainer.GetNode(scene.Asset)[nameof(scene.Asset.Offset)];\n            offsetNodeBinding = new MemberGraphNodeBinding<Vector3>(offsetNode, nameof(Offset), OnPropertyChanging, OnPropertyChanged, Editor.UndoRedoService);\n\n            LoadSettings().Forget();\n        }\n\n        [ItemNotNull, NotNull]\n        public IReadOnlyObservableList<SceneRootViewModel> ChildScenes => childScenes;\n\n        /// <inheritdoc/>\n        public override AbsoluteId Id => new AbsoluteId(Asset.Id, sceneId);\n\n        /// <inheritdoc/>\n        public override IEnumerable<EntityViewModel> InnerSubEntities => ChildrenExceptScenes.SelectMany(x => x.InnerSubEntities);\n\n        /// <inheritdoc />\n        public override string Name { get => Asset.Name; set => throw new NotSupportedException($\"Cannot change the name of a {nameof(SceneRootViewModel)} object.\"); }\n\n        public Vector3 Offset { get => offsetNodeBinding.Value; set => offsetNodeBinding.Value = value; }\n\n        [CanBeNull]\n        public SceneRootViewModel ParentScene => (SceneRootViewModel)Parent;\n\n        [NotNull]\n        public SceneViewModel SceneAsset => (SceneViewModel)Asset;\n\n        /// <summary>\n        /// Index of the first scene in the <see cref=\"EntityHierarchyRootViewModel.Children\"/> property.\n        /// </summary>\n        /// <remarks>\n        /// Scene are inserted after all entities and folders.\n        /// </remarks>\n        private int ChildScenesStartingIndex => Children.Count - ChildScenes.Count;\n\n        [NotNull]","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/SceneEditor/ViewModels/SceneRootViewModel.cs#L51-L87","documentation":"SceneRootViewModel represents a scene nested inside another scene; its Name is read-only and derived from the underlying scene asset. Setting it throws NotSupportedException by design because the name belongs to the scene asset, not this placeholder root node.","triggerScenarios":"Assigning SceneRootViewModel.Name (directly or through a property-grid/rename UI bound to Name) on the root node of a child scene.","commonSituations":"Rename operations applied to all selected hierarchy nodes including scene roots; generic view-model editors that assume Name is writable; scripts that rename nodes during batch operations.","solutions":["Skip SceneRootViewModel nodes in rename operations or rename the underlying Asset instead.","Check the node type before setting Name and surface the scene-asset name editor for scene roots.","Catch NotSupportedException if a generic rename pipeline cannot exclude scene roots."],"exampleFix":"// before\nselectedNode.Name = newName; // throws for scene roots\n// after\nif (selectedNode is SceneRootViewModel sceneRoot)\n    sceneRoot.Asset.Name = newName; // rename the asset\nelse\n    selectedNode.Name = newName;","handlingStrategy":"type-guard","validationCode":"if (node is SceneRootViewModel) { renameAsset(node.Asset, newName); return; }","typeGuard":"static bool SupportsRename(object vm) => vm is not SceneRootViewModel;","tryCatchPattern":"try { node.Name = newName; }\ncatch (NotSupportedException) { ((SceneRootViewModel)node).Asset.Name = newName; }","preventionTips":["Exclude SceneRootViewModel nodes from bulk rename operations.","Rename scene roots through their underlying Asset, not the view model.","Disable the Name field in the property grid for scene roots."],"tags":["unsupported-operation","read-only-property","scene-editor"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}