{"record":{"id":"e10b5a78c3904ef6","repo":"unoplatform/uno","slug":"xamltype-e10b5a","errorCode":null,"errorMessage":"xamlType","messagePattern":"xamlType","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlWriterInternalBase.cs","lineNumber":165,"sourceCode":"\n\t\t\tOnWriteGetObject ();\n\t\t}\n\n\t\tpublic void WriteNamespace (NamespaceDeclaration namespaceDeclaration)\n\t\t{\n\t\t\tif (namespaceDeclaration == null)\n\t\t\t\tthrow new ArgumentNullException (\"namespaceDeclaration\");\n\n\t\t\tmanager.Namespace ();\n\n\t\t\tnamespaces.Add (namespaceDeclaration);\n\t\t\tOnWriteNamespace (namespaceDeclaration);\n\t\t}\n\n\t\tpublic void WriteStartObject (XamlType xamlType)\n\t\t{\n\t\t\tif (xamlType == null)\n\t\t\t\tthrow new ArgumentNullException (\"xamlType\");\n\n\t\t\tmanager.StartObject ();\n\n\t\t\tvar cstate = new ObjectState () {Type = xamlType};\n\t\t\tobject_states.Push (cstate);\n\n\t\t\tOnWriteStartObject ();\n\t\t}\n\t\t\n\t\tpublic void WriteValue (object value)\n\t\t{\n\t\t\tmanager.Value ();\n\n\t\t\tOnWriteValue (value);\n\t\t}\n\t\t\n\t\tpublic void WriteStartMember (XamlMember property)\n\t\t{","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlWriterInternalBase.cs#L147-L183","documentation":"XamlWriterInternalBase.WriteStartObject throws ArgumentNullException('xamlType') when a null XamlType is written. The XamlType is pushed onto the object state stack and used to drive member/type lookups, so a null would break the writer state machine.","triggerScenarios":"Writing a StartObject node for a type that resolved to null — e.g. forwarding a node from a reader whose Type property returned null (reader not positioned on StartObject, or type resolution failed silently).","commonSituations":"Custom XamlReader that returns null from Type when NodeType is StartObject; pipeline code that synthesizes StartObject nodes without a resolved type; tests of the validation guard.","solutions":["Ensure the XamlType is resolved before writing StartObject; if resolution failed, surface that error instead of writing null.","Validate reader.Type is non-null when NodeType == StartObject before forwarding to WriteStartObject.","In custom readers, never return null from the Type property on a StartObject node."],"exampleFix":"// before\nif (reader.NodeType == XamlNodeType.StartObject)\n    writer.WriteStartObject(reader.Type); // reader.Type may be null\n\n// after\nif (reader.NodeType == XamlNodeType.StartObject && reader.Type != null)\n    writer.WriteStartObject(reader.Type);","handlingStrategy":"type-guard","validationCode":"if (reader.NodeType == XamlNodeType.StartObject && reader.Type != null)\n    writer.WriteStartObject(reader.Type);","typeGuard":"static bool CanWriteStartObject(XamlReader r) => r.NodeType == XamlNodeType.StartObject && r.Type is not null;","tryCatchPattern":null,"preventionTips":["Always check reader.Type is non-null when NodeType is StartObject before forwarding.","In custom readers, never return null from the Type property on StartObject nodes."],"tags":["xaml","argument-null","xamlwriter","xamltype"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}