{"record":{"id":"6b030210e3ac2cb2","repo":"stride3d/stride","slug":"fromtext","errorCode":null,"errorMessage":"fromText","messagePattern":"fromText","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Serialization/Serializer.cs","lineNumber":353,"sourceCode":"        /// <param name=\"fromText\">The text.</param>\n        /// <param name=\"existingObject\">The object to deserialize into. If null (the default) then a new object will be created</param>\n        /// <returns>A deserialized object.</returns>\n        public object Deserialize(string fromText, object existingObject = null)\n        {\n            return Deserialize(fromText, null, existingObject);\n        }\n\n        /// <summary>\n        /// Deserializes an object from the specified string. with an expected specific type.\n        /// </summary>\n        /// <param name=\"fromText\">From text.</param>\n        /// <param name=\"expectedType\">The expected type.</param>\n        /// <param name=\"existingObject\">The object to deserialize into. If null (the default) then a new object will be created</param>\n        /// <returns>A deserialized object.</returns>\n        /// <exception cref=\"System.ArgumentNullException\">stream</exception>\n        public object Deserialize(string fromText, Type expectedType, object existingObject = null)\n        {\n            if (fromText == null) throw new ArgumentNullException(nameof(fromText));\n            return Deserialize(new StringReader(fromText), expectedType, existingObject);\n        }\n\n        /// <summary>\n        /// Deserializes an object from the specified string. with an expected specific type.\n        /// </summary>\n        /// <param name=\"fromText\">From text.</param>\n        /// <param name=\"expectedType\">The expected type.</param>\n        /// <param name=\"existingObject\">The object to deserialize into. If null (the default) then a new object will be created</param>\n        /// <param name=\"context\">The context used to deserialize this object.</param>\n        /// <returns>A deserialized object.</returns>\n        /// <exception cref=\"System.ArgumentNullException\">stream</exception>\n        public object Deserialize(string fromText, Type expectedType, object existingObject, out SerializerContext context)\n        {\n            if (fromText == null) throw new ArgumentNullException(nameof(fromText));\n            return Deserialize(new StringReader(fromText), expectedType, existingObject, null, out context);\n        }\n","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Serialization/Serializer.cs#L335-L371","documentation":"The string-based Deserialize overload throws ArgumentNullException(\"fromText\") when the YAML text passed in is null. This is an up-front argument validation; it does not indicate malformed YAML, only a missing input string.","triggerScenarios":"Calling Deserialize(string fromText, Type expectedType, object existingObject) with fromText == null, e.g. File.ReadAllText returned via a path variable that was null, or a resource loader returning null.","commonSituations":"Embedded resource not found and loader returns null; config file read helper swallowing errors and returning null; unit tests passing uninitialized fixture strings.","solutions":["Ensure the YAML string is non-null before calling; use string.Empty if an empty document is intentional.","Fix the loader that returned null (missing resource, failed read) so it throws instead.","Guard with `if (yaml == null)` and raise an application-specific error naming the source.","Catch ArgumentNullException to convert it into a domain error.","Prefer loading via a stream overload with explicit file-not-found handling."],"exampleFix":"// before\nvar yaml = LoadResource(\"config.yaml\"); // returns null when missing\nvar cfg = (Config)serializer.Deserialize(yaml, typeof(Config));\n// after\nvar yaml = LoadResource(\"config.yaml\") ?? throw new FileNotFoundException(\"config.yaml not found\");\nvar cfg = (Config)serializer.Deserialize(yaml, typeof(Config));","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(yaml)) throw new ArgumentException(\"YAML text is null or empty\", nameof(yaml));","typeGuard":"static bool HasYamlText(string s) => !string.IsNullOrEmpty(s);","tryCatchPattern":"try { return serializer.Deserialize(yaml, typeof(Config)); }\ncatch (ArgumentNullException) { throw new InvalidDataException(\"YAML text was not loaded\"); }","preventionTips":["Make resource loaders throw instead of returning null","Validate strings with string.IsNullOrEmpty before deserialize","Load files via File.ReadAllText so missing files raise FileNotFoundException"],"tags":["yaml","null-argument","deserialization"],"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"}