{"record":{"id":"b9adc3766255bb1c","repo":"unoplatform/uno","slug":"reader","errorCode":null,"errorMessage":"reader","messagePattern":"reader","errorType":"exception","errorClass":"ObjectDisposedException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlObjectReader.cs","lineNumber":175,"sourceCode":"\t\t\tget { return sctx; }\n\t\t}\n\n\t\tpublic override XamlType Type {\n\t\t\tget { return NodeType == XamlNodeType.StartObject ? nodes.Current.Object.Type : null; }\n\t\t}\n\n\t\tpublic override object Value {\n\t\t\tget {\n\t\t\t\tif (NodeType != XamlNodeType.Value)\n\t\t\t\t\treturn null;\n\t\t\t\treturn nodes.Current.Value;\n\t\t\t}\n\t\t}\n\n\t\tpublic override bool Read ()\n\t\t{\n\t\t\tif (IsDisposed)\n\t\t\t\tthrow new ObjectDisposedException (\"reader\");\n\t\t\tif (IsEof)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\tif (ns_iterator == null)\n\t\t\t\tns_iterator = PrefixLookup.Namespaces.GetEnumerator ();\n\t\t\tif (ns_iterator.MoveNext ())\n\t\t\t\treturn true;\n\t\t\tif (nodes == null)\n\t\t\t\tnodes = new XamlObjectNodeIterator (root, sctx, value_serializer_context).GetNodes ().GetEnumerator ();\n\t\t\tif (nodes.MoveNext ())\n\t\t\t\treturn true;\n\t\t\tif (!is_eof)\n\t\t\t\tis_eof = true;\n\t\t\treturn false;\n\t\t}\n\t}\n}\n","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlObjectReader.cs#L157-L193","documentation":"Thrown by XamlObjectReader.Read as an ObjectDisposedException (object name 'reader') when IsDisposed is true. This indicates the reader was disposed (via Close/Dispose) and Read() was called afterward — the underlying node stream is gone and reading is no longer valid.","triggerScenarios":"Calling Read() after Close() or Dispose() on the same XamlObjectReader instance. Or holding a stale reader reference in a reused pipeline and calling Read in a second pass.","commonSituations":"XAML processing loops that use using(var reader = ...) blocks but then attempt to read outside the block. Reader pooling/reuse that calls Read after a prior consumer disposed the reader. Error-recovery paths that dispose on failure but continue iterating.","solutions":["Do not call Read() after the reader is disposed — scope all reads within the using block.","Track disposal state in your pipeline and skip or recreate the reader for subsequent passes.","Create a fresh XamlObjectReader for each read pass rather than reusing a disposed one."],"exampleFix":"// before\nusing (var reader = new XamlObjectReader(obj, sctx))\n{\n    while (reader.Read()) Process(reader);\n} // disposed here\nreader.Read(); // throws ObjectDisposedException\n\n// after\nusing (var reader = new XamlObjectReader(obj, sctx))\n{\n    while (reader.Read()) Process(reader);\n}\n// if you need to read again, create a new reader\nusing (var reader2 = new XamlObjectReader(obj, sctx))\n{\n    while (reader2.Read()) Process(reader2);\n}","handlingStrategy":"validation","validationCode":"if (reader.IsDisposed) throw new ObjectDisposedException(\"reader was disposed\");\nreader.Read();","typeGuard":null,"tryCatchPattern":"try { reader.Read(); }\ncatch (ObjectDisposedException) { /* recreate reader */ }","preventionTips":["Scope all Read() calls within the using block that owns the reader.","Do not hold stale reader references across disposal boundaries.","Create a new reader per read pass."],"tags":["xaml","object-disposed","object-reader","lifecycle","uno-xaml"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}