{"record":{"id":"68633740526796d2","repo":"stride3d/stride","slug":"argumentnullexception-child","errorCode":null,"errorMessage":"ArgumentNullException: child","messagePattern":"ArgumentNullException: child","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/ViewModel/SceneViewModel.cs","lineNumber":72,"sourceCode":"        [CanBeNull]\n        public SceneViewModel Parent { get { return parent; } private set { SetValueUncancellable(ref parent, value, ParentPropertyChanged); } }\n\n        [NotNull]\n        internal ICommandBase SetAsDefaultCommand { get; }\n\n        /// <summary>\n        /// Checks whether this scene can be a parent of the provided <paramref name=\"child\"/> scene.\n        /// </summary>\n        /// <param name=\"child\">The potential child of this scene.</param>\n        /// <param name=\"message\">A message providing more details on why this scene can -or cannot- be a parent.</param>\n        /// <param name=\"checkSameParent\">\n        /// <c>true</c> to also check if this scene is already a parent of the provided <paramref name=\"child\"/> scene; otherwise, <c>false</c>.\n        /// The default is <c>false</c>.\n        /// </param>\n        /// <returns><c>true</c> if this scene can be of parent of the provided <paramref name=\"child\"/> scene; otherwise, <c>false</c>.</returns>\n        public bool CanBeParentOf([NotNull] SceneViewModel child, [NotNull] out string message, bool checkSameParent = false)\n        {\n            if (child == null) throw new ArgumentNullException(nameof(child));\n\n            if (child == this)\n            {\n                message = \"Can't be a parent of itself\";\n                return false;\n            }\n            if (checkSameParent && child.Parent == this)\n            {\n                message = \"Scene already has this parent\";\n                return false;\n            }\n            var scene = Parent;\n            while (scene != null)\n            {\n                if (scene == child)\n                {\n                    message = \"Circular scene hierarchy\";\n                    return false;","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/ViewModel/SceneViewModel.cs#L54-L90","documentation":"SceneViewModel.CanBeParentOf checks whether one scene can be a parent of another. The child parameter is mandatory; passing null throws ArgumentNullException(nameof(child)) since the parentability check cannot be evaluated for a missing scene.","triggerScenarios":"Calling CanBeParentOf with a null SceneViewModel child — e.g. drag-and-drop handlers computing parent validity before resolving the dragged item, or filtering scenes where a reference was not yet resolved.","commonSituations":"Custom editor plugins implementing drag/drop reparenting that call CanBeParentOf with a null candidate; UI bindings passing null while a drag operation is in flight.","solutions":["Check the dragged/target SceneViewModel is non-null before calling CanBeParentOf","Resolve the SceneViewModel from the drag payload first; abort the drag if resolution fails","Change the call site to return early (treat null child as not parentable) instead of querying"],"exampleFix":"// before\nbool ok = scene.CanBeParentOf(draggedScene, out msg);\n// after\nbool ok = draggedScene != null && scene.CanBeParentOf(draggedScene, out msg);","handlingStrategy":"type-guard","validationCode":"if (child == null) { message = \"No target scene\"; return false; }","typeGuard":"bool CanEvaluate(SceneViewModel child) => child != null;","tryCatchPattern":"try { return scene.CanBeParentOf(child, out msg); }\ncatch (ArgumentNullException) { return false; // null child can never be parented\n}","preventionTips":["Resolve drag payloads to SceneViewModel before computing parent validity","Treat null child references as 'not parentable' early in drag/drop handlers","Null-check references after scene renames/moves that may invalidate cached view models"],"tags":["stride","editor","null"],"backgroundTag":"null-argument","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"}