{"record":{"id":"a71a8e4ccddb5f9c","repo":"stride3d/stride","slug":"objectfactory-can-not-be-null","errorCode":null,"errorMessage":"ObjectFactory can not be null","messagePattern":"ObjectFactory can not be null","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Serialization/SerializerSettings.cs","lineNumber":305,"sourceCode":"            {\n                if (value == null)\n                    throw new ArgumentNullException(\"value\", $\"{nameof(ObjectSerializerBackend)} can not be null\");\n                objectSerializerBackend = value;\n            }\n        }\n\n        /// <summary>\n        /// Gets or sets the default factory to instantiate a type. Default is <see cref=\"DefaultObjectFactory\" />.\n        /// </summary>\n        /// <value>The default factory to instantiate a type.</value>\n        /// <exception cref=\"System.ArgumentNullException\">value</exception>\n        public IObjectFactory ObjectFactory\n        {\n            get { return objectFactory; }\n            set\n            {\n                if (value == null)\n                    throw new ArgumentNullException(\"value\", $\"{nameof(ObjectFactory)} can not be null\");\n                objectFactory = value;\n            }\n        }\n\n        /// <summary>\n        /// Gets or sets the schema. Default is <see cref=\"CoreSchema\" />.\n        /// method.\n        /// </summary>\n        /// <value>The schema.</value>\n        /// <exception cref=\"System.ArgumentNullException\">value</exception>\n        public IYamlSchema Schema { get { return schema; } }\n\n        public ISerializerFactorySelector SerializerFactorySelector { get; set; }\n\n        /// <summary>\n        /// Gets a methods that will build the proper chain of serializers out of the default chain.\n        /// </summary>\n        public Action<ChainedSerializer> ChainedSerializerFactory { get; set; }","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Serialization/SerializerSettings.cs#L287-L323","documentation":"Null-assignment guard on SerializerSettings.ObjectFactory (context: the adjacent ObjectSerializerBackend property uses this pattern): assigning null would leave the serializer without a way to instantiate objects, so the setter rejects a null value. The faulting input is the value assigned to the property.","triggerScenarios":"`settings.ObjectFactory = null`, or passing a result of an unregistered container resolve that returns null.","commonSituations":"Custom object factories wired through a DI container that was not fully built; settings copied between test and production code.","solutions":["Assign a valid IObjectFactory (e.g. DefaultObjectFactory or your custom implementation)","Correct the container registration so the factory resolves to a non-null instance"],"exampleFix":"// before\nsettings.ObjectFactory = null;\n// after\nsettings.ObjectFactory = new DefaultObjectFactory(serviceRegistry);","handlingStrategy":"validation","validationCode":"settings.ObjectFactory = factory ?? new DefaultObjectFactory();","typeGuard":null,"tryCatchPattern":"try { settings.ObjectFactory = factory; } catch (ArgumentNullException) { settings.ObjectFactory = new DefaultObjectFactory(); }","preventionTips":["Fall back to the default factory instead of null","Test container resolution for IObjectFactory during startup"],"tags":["yaml","serialization","null-argument","configuration"],"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"}