{"record":{"id":"e68c65feac378b42","repo":"stride3d/stride","slug":"cannot-change-the-parent-of-an-assetmountpointviewmodel","errorCode":null,"errorMessage":"Cannot change the parent of an AssetMountPointViewModel","messagePattern":"Cannot change the parent of an AssetMountPointViewModel","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/ViewModel/MountPointViewModel.cs","lineNumber":20,"sourceCode":"// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Stride.Core.Presentation.Dirtiables;\n\nnamespace Stride.Core.Assets.Editor.ViewModel\n{\n    public abstract class MountPointViewModel : DirectoryBaseViewModel\n    {\n        protected MountPointViewModel(PackageViewModel package)\n            : base(package.Session)\n        {\n            Package = package;\n        }\n\n        public override string Path => string.Empty;\n\n        public override DirectoryBaseViewModel Parent { get { return null; } set { throw new InvalidOperationException(\"Cannot change the parent of an AssetMountPointViewModel\"); } }\n\n        public override MountPointViewModel Root => this;\n\n        public override PackageViewModel Package { get; }\n\n        /// <inheritdoc/>\n        public override string TypeDisplayName => \"Mount Point\";\n\n        /// <inheritdoc/>\n        public override IEnumerable<IDirtiable> Dirtiables => base.Dirtiables.Concat(Package.Dirtiables);\n\n        public IReadOnlyCollection<DirectoryBaseViewModel> GetDirectoryHierarchy()\n        {\n            var hierarchy = new List<DirectoryBaseViewModel>();\n            GetDirectoryHierarchy(hierarchy);\n            return hierarchy;\n        }\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/ViewModel/MountPointViewModel.cs#L2-L38","documentation":"MountPointViewModel represents the root mount point of a package in the asset tree; its Parent is defined as always null. The Parent setter throws InvalidOperationException because a mount point can never be attached to another directory.","triggerScenarios":"Assigning the Parent property of a MountPointViewModel, or calling DirectoryBaseViewModel.SetParent with a mount point as the target.","commonSituations":"Generic tree/drag-drop code that moves any DirectoryBaseViewModel node, accidentally picking a package's mount point as the drag source or drop child.","solutions":["Never set Parent on a MountPointViewModel; treat it as a fixed root","Check the node type before attempting reparent operations","Operate on DirectoryViewModel children instead of the mount point itself"],"exampleFix":"// before\nmountPoint.Parent = targetFolder;\n// after\nif (mountPoint is DirectoryViewModel dir) { dir.Parent = targetFolder; }","handlingStrategy":"type-guard","validationCode":"if (node is MountPointViewModel) throw new ArgumentException(\"Mount points cannot be reparented\");","typeGuard":"bool CanSetParent(DirectoryBaseViewModel n) => n is DirectoryViewModel;","tryCatchPattern":"try { node.Parent = target; } catch (InvalidOperationException) { /* mount point: parent is fixed null */ }","preventionTips":["Treat mount points as fixed roots","Type-check before tree mutations","Skip mount points in drag-drop handlers"],"tags":["viewmodel","mount-point","immutable"],"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"}