{"record":{"id":"5519e06a77da94f7","repo":"dotnet/wpf","slug":"sr-whitespaceafterme","errorCode":null,"errorMessage":"SR.WhitespaceAfterME","messagePattern":"SR\\.WhitespaceAfterME","errorType":"exception","errorClass":"XamlParseException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MePullParser.cs","lineNumber":78,"sourceCode":"            {\n                yield return node;\n            }\n\n            if (!f.found)\n            {\n                string brokenRule = _brokenRule;\n                _brokenRule = null;\n                throw new XamlParseException(_tokenizer, brokenRule);\n            }\n\n            if (_tokenizer.Token != MeTokenType.None)\n            {\n                throw new XamlParseException(_tokenizer, SR.UnexpectedTokenAfterME);\n            }\n\n            if (_tokenizer.HasTrailingWhitespace)\n            {\n                throw new XamlParseException(_tokenizer, SR.WhitespaceAfterME);\n            }\n        }\n\n        private void SetBrokenRuleString(string ruleString)\n        {\n            if (string.IsNullOrEmpty(_brokenRule))\n            {\n                _brokenRule = SR.Format(SR.UnexpectedToken,\n                                            _tokenizer.Token, ruleString, _originalText);\n            }\n        }\n\n        private bool Expect(MeTokenType token, string ruleString)\n        {\n            if (_tokenizer.Token != token)\n            {\n                SetBrokenRuleString(ruleString);\n                return false;","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MePullParser.cs#L60-L96","documentation":"MePullParser.Parse rejects a markup extension that has trailing whitespace after its terminating token, throwing XamlParseException(SR.WhitespaceAfterME). This strictness prevents ambiguous or unintended values like '{Binding Path}  '.","triggerScenarios":"Markup-extension attribute values containing whitespace after the closing '}', e.g. ' {Binding Path} ' or '{StaticResource Foo} '.","commonSituations":"Whitespace introduced by XML formatting, template value strings with surrounding spaces, programmatic string concatenation appending a newline.","solutions":["Trim the markup-extension string before assigning/parsing","Rewrite the attribute value so '}' is the last character","Use string.Trim() on dynamically composed values"],"exampleFix":"// before\nvalue = \"{StaticResource Foo} \";\n// after\nvalue = \"{StaticResource Foo}\".Trim();","handlingStrategy":"validation","validationCode":"string Sanitize(string s) => s?.Trim();\nbool HasTrailingWs(string s) => s != null && s.Length > 0 && char.IsWhiteSpace(s[s.Length-1]);","typeGuard":null,"tryCatchPattern":"try { nodes = parser.Parse(meString.Trim()); }\ncatch (XamlParseException ex) when (ex.Message.Contains(\"whitespace\")) { /* normalize the source string */ }","preventionTips":["Always Trim() strings destined for markup-extension parsing","Avoid template/format strings that append trailing spaces","Normalize values at the persistence layer"],"tags":["xaml","markup-extension","whitespace"],"backgroundTag":"invalid-argument-format","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}