{"record":{"id":"8450c9b5279f3941","repo":"stride3d/stride","slug":"argumentnullexception-nodecontainer","errorCode":null,"errorMessage":"ArgumentNullException: nodeContainer","messagePattern":"ArgumentNullException: nodeContainer","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/Components/Properties/PropertiesViewModel.cs","lineNumber":44,"sourceCode":"    {\n        protected readonly GraphViewModelService ViewModelService;\n        protected readonly NodeContainer NodeContainer;\n        private readonly object lockObject = new object();\n\n        private GraphViewModel viewModel;\n        private bool canDisplayProperties;\n        private string fallbackMessage;\n        private int currentToken;\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"PropertiesViewModel\"/> class.\n        /// </summary>\n        /// <param name=\"serviceProvider\">The view model service provider to use.</param>\n        /// <param name=\"nodeContainer\">The <see cref=\"NodeContainer\"/> containing the nodes used to access object properties.</param>\n        protected PropertiesViewModel([NotNull] IViewModelServiceProvider serviceProvider, [NotNull] NodeContainer nodeContainer)\n            : base(serviceProvider)\n        {\n            if (nodeContainer == null) throw new ArgumentNullException(nameof(nodeContainer));\n            NodeContainer = nodeContainer;\n\n            // Create the service needed to manage graph view models\n            ViewModelService = new GraphViewModelService(nodeContainer);\n\n            // Update the service provider of this view model to contains the GraphViewModelService we created.\n            ServiceProvider = new ViewModelServiceProvider(serviceProvider, ViewModelService.Yield());\n\n            RegisterNodePresenterCommand(new CreateNewInstanceCommand());\n            RegisterNodePresenterCommand(new AddNewItemCommand());\n            RegisterNodePresenterCommand(new AddPrimitiveKeyCommand());\n            RegisterNodePresenterCommand(new RemoveItemCommand());\n            RegisterNodePresenterCommand(new RenameStringKeyCommand());\n            RegisterNodePresenterCommand(new MoveItemCommand());\n            RegisterNodePresenterCommand(new FlagEnumSelectAllCommand());\n            RegisterNodePresenterCommand(new FlagEnumSelectNoneCommand());\n            RegisterNodePresenterCommand(new FlagEnumSelectInvertCommand());\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/Components/Properties/PropertiesViewModel.cs#L26-L62","documentation":"The protected PropertiesViewModel constructor requires a NodeContainer that provides access to the inspected object's property nodes, and throws ArgumentNullException when it is null. The container is stored and used to create the GraphViewModelService.","triggerScenarios":"Deriving from PropertiesViewModel and calling the base constructor with nodeContainer == null.","commonSituations":"Building a custom properties/editor view model where the NodeContainer came from an unresolved session or a not-yet-initialized node system.","solutions":["Pass the valid NodeContainer from the session/asset node system","Obtain it via NodeContainerFactory/ISessionService before constructing the view model","Initialize the node container earlier in the view-model construction chain"],"exampleFix":"// before\npublic MyPropertiesViewModel(IViewModelServiceProvider sp) : base(sp, GetContainer()) { }\n// after\npublic MyPropertiesViewModel(IViewModelServiceProvider sp) : base(sp, GetContainer() ?? throw new InvalidOperationException(\"NodeContainer not available\")) { }","handlingStrategy":"type-guard","validationCode":"if (nodeContainer == null) throw new InvalidOperationException(\"NodeContainer must be resolved before creating PropertiesViewModel\");","typeGuard":"static bool HasNodeContainer([NotNullWhen(true)] NodeContainer? nc) => nc is not null;","tryCatchPattern":"try { base(serviceProvider, nodeContainer); } catch (ArgumentNullException ex) { logger.LogCritical(ex, \"NodeContainer missing in PropertiesViewModel\"); throw; }","preventionTips":["Resolve the NodeContainer from the session before constructing derived view models","Order initialization so node infrastructure exists before property views","Enforce non-null base constructor arguments in derived class factories"],"tags":["null-argument","viewmodel","node-container"],"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"}