{"record":{"id":"a1a2792c0e3a3b2d","repo":"stride3d/stride","slug":"argumentnullexception-removeaction","errorCode":null,"errorMessage":"ArgumentNullException: removeAction","messagePattern":"ArgumentNullException: removeAction","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/Components/TemplateDescriptions/ViewModels/ExistingProjectViewModel.cs","lineNumber":24,"sourceCode":"using System.Linq;\nusing System.Windows.Media.Imaging;\nusing Stride.Core.Assets.Templates;\nusing Stride.Core.IO;\nusing Stride.Core.Presentation.Commands;\nusing Stride.Core.Presentation.ViewModels;\n\nnamespace Stride.Core.Assets.Editor.Components.TemplateDescriptions.ViewModels\n{\n    public class ExistingProjectViewModel : DispatcherViewModel, ITemplateDescriptionViewModel\n    {\n        private Action<ExistingProjectViewModel> RemoveAction;\n\n        public ExistingProjectViewModel(IViewModelServiceProvider serviceProvider, UFile path, Action<ExistingProjectViewModel> removeAction)\n            : base(serviceProvider)\n        {\n            Path = path;\n            Id = Guid.NewGuid();\n            RemoveAction = removeAction ?? throw new ArgumentNullException(nameof(removeAction));\n            ExploreCommand = new AnonymousCommand(serviceProvider, Explore);\n            RemoveCommand = new AnonymousCommand(serviceProvider, Remove);\n        }\n\n        public string Name => Path.GetFileNameWithoutExtension();\n\n        public string Description => Path.ToOSPath();\n\n        public string FullDescription => \"\";\n\n        public string Group => \"\";\n\n        public Guid Id { get; }\n\n        public string DefaultOutputName => \"\";\n\n        public UFile Path { get; }\n        // TODO","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/Components/TemplateDescriptions/ViewModels/ExistingProjectViewModel.cs#L6-L42","documentation":"Argument-null validation in the ExistingProjectViewModel constructor: the removeAction callback is null. This callback is stored and later invoked to remove the existing-project entry from the template description; without it the view model cannot fulfill its removal behavior, so construction is aborted.","triggerScenarios":"Constructing ExistingProjectViewModel with null removeAction, e.g. when the owning collection view model passes a delegate lazily or a callback was not wired up.","commonSituations":"Parent view model built before its remove callback exists; refactoring that dropped the delegate argument; lambda replaced by an uninitialized field.","solutions":["Always pass a non-null Action<ExistingProjectViewModel> when constructing the view model","Pass a no-op or logged delegate if removal is intentionally unsupported in a context","Initialize the remove callback before creating ExistingProjectViewModel instances"],"exampleFix":"// before\nnew ExistingProjectViewModel(serviceProvider, path, removeAction); // removeAction may be null\n// after\nnew ExistingProjectViewModel(serviceProvider, path, removeAction ?? (_ => { }));","handlingStrategy":"validation","validationCode":"if (removeAction == null) throw new ArgumentException(\"Remove callback is required\", nameof(removeAction));","typeGuard":"bool CanCreate(IViewModelServiceProvider sp, UFile path, Action<ExistingProjectViewModel> remove) => sp != null && path != null && remove != null;","tryCatchPattern":"try { new ExistingProjectViewModel(sp, path, removeAction); } catch (ArgumentNullException ex) when (ex.ParamName == \"removeAction\") { /* fix constructor wiring */ }","preventionTips":["Wire remove callbacks before constructing item view models","Pass an explicit no-op delegate when removal is unsupported","Constructor-review view models for required delegates"],"tags":["null-argument","viewmodel","constructor"],"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"}