{"record":{"id":"350c63d4c23d33ac","repo":"dotnet/wpf","slug":"notimplementedexception-sr-missingcasexamlnodes","errorCode":null,"errorMessage":"NotImplementedException(SR.MissingCaseXamlNodes)","messagePattern":"NotImplementedException\\(SR\\.MissingCaseXamlNodes\\)","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlWriter.cs","lineNumber":59,"sourceCode":"                break;\n\n            case XamlNodeType.StartMember:\n                WriteStartMember(reader.Member);\n                break;\n\n            case XamlNodeType.EndMember:\n                WriteEndMember();\n                break;\n\n            case XamlNodeType.Value:\n                WriteValue(reader.Value);\n                break;\n\n            case XamlNodeType.None:\n                break;\n\n            default:\n                throw new NotImplementedException(SR.MissingCaseXamlNodes);\n            }\n        }\n\n        #region IDisposable\n\n        // See Framework Design Guidelines, pp. 254-256.\n\n        protected bool IsDisposed { get; private set; }\n\n        void IDisposable.Dispose()\n        {\n            Dispose(true);\n            GC.SuppressFinalize(this);\n        }\n\n        protected virtual void Dispose(bool disposing)\n        {\n            IsDisposed = true; // must call the base class to get IsDisposed == true;","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlWriter.cs#L41-L77","documentation":"XamlWriter.WriteNode's switch over XamlNodeType has no handler for the node type it received, so it hits the default case and throws NotImplementedException. This is an internal exhaustiveness guard: the writer supports only the concrete XAML node kinds (Start/End Object, Start/End Member, Value, Namespace, None), and anything else is unsupported.","triggerScenarios":"Feeding a XamlReader-produced node stream containing a node type WriteNode doesn't handle into XamlServices/xamlWriter.WriteNode; passing XamlNodeType.None-like or corrupted nodes from a custom IXamlReader implementation.","commonSituations":"Custom XAML readers/writers that emit non-standard node types; mixing nodes from different System.Xaml versions; piping a reader's GetReader results through a transform into XamlXmlWriter with an unexpected node in the stream.","solutions":["Ensure the source IXamlReader only emits standard XamlNodeType values; fix or replace the custom reader.","Filter or transform unexpected nodes (e.g. via XamlNodeQueue/XamlNodeEnumerator) before calling WriteNode.","Update System.Xaml/pipeline components so reader and writer node-type enums match.","Add an explicit case/handling if you own a node type extension point."],"exampleFix":"// before\nwhile (reader.Read()) writer.WriteNode(reader); // NotImplementedException on unknown node\n// after\nwhile (reader.Read())\n{\n    if (reader.NodeType == XamlNodeType.None) continue; // skip unsupported nodes\n    writer.WriteNode(reader);\n}","handlingStrategy":"try-catch","validationCode":"if (node is null || !Enum.IsDefined(typeof(XamlNodeType), node.NodeType))\n    throw new InvalidOperationException(\"Unsupported XAML node type in stream\");","typeGuard":"bool IsWritableNode(IXamlReader r) => r.NodeType is XamlNodeType.StartObject or XamlNodeType.EndObject\n    or XamlNodeType.StartMember or XamlNodeType.EndMember or XamlNodeType.Value or XamlNodeType.Namespace or XamlNodeType.None;","tryCatchPattern":"try { writer.WriteNode(reader); }\ncatch (NotImplementedException ex) { /* log node type; filter/skip node or fix custom reader */ }","preventionTips":["Only pipe nodes from well-behaved IXamlReader implementations.","Filter the node stream (skip XamlNodeType.None and unknown kinds) before writing.","Keep System.Xaml reader/writer versions aligned in mixed pipelines."],"tags":["xaml","not-implemented","node-stream"],"backgroundTag":"method-not-implemented","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}