{"record":{"id":"33da6d6ddf63807d","repo":"stride3d/stride","slug":"argumentnullexception-deletedobjects","errorCode":null,"errorMessage":"ArgumentNullException: deletedObjects","messagePattern":"ArgumentNullException: deletedObjects","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/Components/FixReferences/FixReferencesViewModel.cs","lineNumber":136,"sourceCode":"        /// <summary>\n        /// Gets a command that indicates to clear the references for the <see cref=\"CurrentObjectToReplace\"/> and\n        /// move the next object to fix (or complete the process if the current object is the last one).\n        /// </summary>\n        public ICommandBase ClearReferencesCommand { get; }\n\n        /// <summary>\n        /// Gets a command that indicates to clear the references for the <see cref=\"CurrentObjectToReplace\"/> and\n        /// the following object to fix, and complete the process if the current object is the last one.\n        /// </summary>\n        public ICommandBase ClearAllReferencesCommand { get; }\n\n        /// <summary>\n        /// Initializes this view model with the given collection of deleted objects\n        /// </summary>\n        /// <param name=\"deletedObjects\">The collection of deleted objects for which to fix references.</param>\n        public void Initialize(IEnumerable<T> deletedObjects)\n        {\n            if (deletedObjects == null) throw new ArgumentNullException(nameof(deletedObjects));\n            \n            foreach (var deletedObject in deletedObjects)\n            {\n                // ReSharper disable once DoNotCallOverridableMethodsInConstructor - this is intended here\n                var referencers = FindReferencers(deletedObject);\n                foreach (var referencer in referencers)\n                {\n                    if (referencer.Value.Count > 0)\n                        referencersMap.Add(new ReferenceTarget(deletedObject, referencer.Key), referencer.Value);\n                }\n            }\n\n            // Go to the first object to fix.\n            NextReferenceIssue();\n        }\n\n        /// <summary>\n        /// Updates the enabled status of the commands.","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/Components/FixReferences/FixReferencesViewModel.cs#L118-L154","documentation":"FixReferencesViewModel<T>.Initialize(IEnumerable<T>) throws ArgumentNullException when deletedObjects is null. The method iterates the collection to find referencers of each deleted object, so a null collection cannot be processed.","triggerScenarios":"Calling Initialize(null) on a FixReferencesViewModel<T> before showing the fix-references dialog.","commonSituations":"Deleted-asset selection was empty/null when the fix-references flow started (e.g. batch delete with no snapshot of the deleted items).","solutions":["Pass a non-null collection (Enumerable.Empty<T>() when nothing was deleted)","Guard the caller: skip Initialize/dialog when the deleted set is null","Collect deleted objects before invoking the fix-references flow"],"exampleFix":"// before\nviewModel.Initialize(deletedObjects);\n// after\nviewModel.Initialize(deletedObjects ?? Enumerable.Empty<AssetViewModel>());","handlingStrategy":"validation","validationCode":"if (deletedObjects == null) deletedObjects = Enumerable.Empty<T>();\nviewModel.Initialize(deletedObjects);","typeGuard":"static bool HasDeletedObjects<T>([NotNullWhen(true)] IEnumerable<T>? items) => items != null;","tryCatchPattern":"try { viewModel.Initialize(deletedObjects); } catch (ArgumentNullException ex) { logger.LogError(ex, \"Initialize requires a collection\"); }","preventionTips":["Pass empty collections rather than null for optional sets","Snapshot deleted items before starting the fix-references flow","Guard UI entry points that depend on prior selection state"],"tags":["null-argument","viewmodel","initialize"],"backgroundTag":"null-argument","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"}