{"record":{"id":"6a13c407a3d325d2","repo":"unoplatform/uno","slug":"xamlwriter","errorCode":null,"errorMessage":"xamlWriter","messagePattern":"xamlWriter","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlServices.cs","lineNumber":115,"sourceCode":"\t\tpublic static void Save (XamlWriter writer, object instance)\n\t\t{\n\t\t\tif (writer == null)\n\t\t\t\tthrow new ArgumentNullException (\"writer\");\n\t\t\tvar r = new XamlObjectReader (instance, writer.SchemaContext);\n\t\t\tTransform (r, writer);\n\t\t}\n\n\t\tpublic static void Transform (XamlReader xamlReader, XamlWriter xamlWriter)\n\t\t{\n\t\t\tTransform (xamlReader, xamlWriter, true);\n\t\t}\n\n\t\tpublic static void Transform (XamlReader xamlReader, XamlWriter xamlWriter, bool closeWriter)\n\t\t{\n\t\t\tif (xamlReader == null)\n\t\t\t\tthrow new ArgumentNullException (\"xamlReader\");\n\t\t\tif (xamlWriter == null)\n\t\t\t\tthrow new ArgumentNullException (\"xamlWriter\");\n\n\t\t\tif (xamlReader.NodeType == XamlNodeType.None)\n\t\t\t\txamlReader.Read ();\n\n\t\t\twhile (!xamlReader.IsEof) {\n\t\t\t\txamlWriter.WriteNode (xamlReader);\n\t\t\t\txamlReader.Read ();\n\t\t\t}\n\t\t\tif (closeWriter)\n\t\t\t\txamlWriter.Close ();\n\t\t}\n\t}\n}\n","sourceCodeStart":97,"sourceCodeEnd":129,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlServices.cs#L97-L129","documentation":"XamlServices.Transform(XamlReader, XamlWriter, bool) throws ArgumentNullException('xamlWriter') when the writer argument is null. Without a destination writer the transform has nowhere to emit nodes, so it fails fast.","triggerScenarios":"Passing a null XamlWriter into Transform, typically when the writer was constructed conditionally (e.g. only when an output stream opened successfully).","commonSituations":"Output setup failure swallowed and null propagated into Transform; refactoring that removed writer creation; tests verifying guard behavior.","solutions":["Null-check the writer before calling Transform and surface the upstream failure.","Make the writer factory throw on construction failure rather than return null.","Prefer XamlServices.Save which manages writer construction internally."],"exampleFix":"// before\nXamlServices.Transform(reader, writer);\n\n// after\nif (writer == null) throw new ArgumentNullException(nameof(writer));\nXamlServices.Transform(reader, writer);","handlingStrategy":"validation","validationCode":"if (xamlWriter == null) throw new ArgumentNullException(nameof(xamlWriter));\nXamlServices.Transform(xamlReader, xamlWriter);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make writer factories throw on construction failure instead of returning null.","Enable nullable reference types to catch null at compile time."],"tags":["xaml","argument-null","xamlservices","transform"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}