{"record":{"id":"92cbcb110528a4c4","repo":"dotnet/wpf","slug":"emptypropertyelement-emptypropertyelement","errorCode":null,"errorMessage":"EmptyPropertyElement ::= EMPTYPROPERTYELEMENT.","messagePattern":"EmptyPropertyElement ::= EMPTYPROPERTYELEMENT\\.","errorType":"exception","errorClass":"XamlUnexpectedParseException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlPullParser.cs","lineNumber":351,"sourceCode":"                    {\n                        yield return node;\n                    }\n\n                    break;\n                default:\n                    throw new XamlUnexpectedParseException(_xamlScanner, nodeType,\n                        PropertyElementRuleException);\n            }\n        }\n\n        ///////////////////////////\n        //  EmptyPropertyElement ::= EMPTYPROPERTYELEMENT\n        //\n        public IEnumerable<XamlNode> P_EmptyPropertyElement()\n        {\n            if (_xamlScanner.NodeType != ScannerNodeType.EMPTYPROPERTYELEMENT)\n            {\n                throw new XamlUnexpectedParseException(_xamlScanner, _xamlScanner.NodeType,\n                    EmptyPropertyElementRuleException);\n            }\n\n            yield return Logic_StartMember(_xamlScanner.PropertyElement);\n            yield return Logic_EndMember();\n            _xamlScanner.Read();\n            if (ProvideLineInfo)\n            {\n                yield return Logic_LineInfo();\n            }\n        }\n\n        ///////////////////////////\n        //  NonemptyPropertyElement ::= PROPERTYELEMENT PropertyContent* ENDTAG\n        //\n        public IEnumerable<XamlNode> P_NonemptyPropertyElement()\n        {\n            if (_xamlScanner.NodeType != ScannerNodeType.PROPERTYELEMENT)","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlPullParser.cs#L333-L369","documentation":"P_EmptyPropertyElement implements EmptyPropertyElement ::= EMPTYPROPERTYELEMENT. It throws XamlUnexpectedParseException if the scanner's current node is not an EMPTYPROPERTYELEMENT, i.e. the parser expected a self-closing property element but found a different node kind. The library throws this to enforce that this production is only invoked at the correct scanner state.","triggerScenarios":"Internal parser dispatch reaches P_EmptyPropertyElement (via P_PropertyElement) while _xamlScanner.NodeType != ScannerNodeType.EMPTYPROPERTYELEMENT — a parser/scanner desynchronization caused by malformed or non-canonical markup.","commonSituations":"Malformed XAML where a property element position contains a non-empty element or other token; custom IXamlXmlParser pipelines feeding nodes out of order; bugs in third-party markup that mimics property elements.","solutions":["Correct the markup so the empty property element is truly self-closing (e.g. <Grid.RowDefinitions/>) at the reported position","Re-run the scanner from a clean stream; do not reuse a partially consumed XamlXmlReader","Verify no custom node-stream injection (XamlNodeList rewinding) is desynchronizing NodeType"],"exampleFix":"// before\n<Grid.RowDefinitions>\n</Grid.RowDefinitions>\n// after (or a fully-formed nonempty element)\n<Grid.RowDefinitions>\n  <RowDefinition Height=\"Auto\" />\n</Grid.RowDefinitions>","handlingStrategy":"validation","validationCode":"if (!xaml.TrimEnd().EndsWith(\"/>\")) throw new InvalidOperationException(\"Expected self-closing property element\");","typeGuard":null,"tryCatchPattern":"try { reader.Read(); /* node loop */ } catch (System.Xaml.XamlParseException ex) { HandleParseFailure(ex.LineNumber, ex.LinePosition, ex.Message); }","preventionTips":["Write empty property elements as <Owner.Property/> when they have no content","Verify scanner state only advances through the public XamlXmlReader API","Round-trip markup through XamlXmlWriter to normalize node forms"],"tags":["xaml","parser","wpf","grammar"],"backgroundTag":"xml-parse-error","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"}