{"record":{"id":"fa2177e93e5dd354","repo":"dotnet/wpf","slug":"sr-unclosedquote","errorCode":null,"errorMessage":"SR.UnclosedQuote","messagePattern":"SR\\.UnclosedQuote","errorType":"exception","errorClass":"XamlParseException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs","lineNumber":512,"sourceCode":"                        {\n                            if (_context.CurrentBracketModeParseParameters?.BracketCharacterStack.Count > 0)\n                            {\n                                throw new XamlParseException(this, SR.Format(SR.MalformedBracketCharacters, ch.ToString()));\n                            }\n                        }\n\n                        PushBack();\n                        break;  // we are done.\n                    }\n                }\n\n                atStart = false;\n                Advance();\n            }\n\n            if (quoteChar != NullChar)\n            {\n                throw new XamlParseException(this, SR.UnclosedQuote);\n            }\n\n            string result = sb.ToString();\n            if (!wasQuoted)\n            {\n                result = result.TrimEnd(KnownStrings.WhitespaceChars);\n                result = result.TrimStart(KnownStrings.WhitespaceChars);\n            }\n\n            if (_state == StringState.Property)\n            {\n                _currentParameterName = result;\n                _currentSpecialBracketCharacters = GetBracketCharacterForProperty(_currentParameterName);\n            }\n\n            return result;\n        }\n","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs#L494-L530","documentation":"MeScanner.ReadString opens a quote at the start of a token and expects it to be closed before the value ends. If ReadString finishes scanning with quoteChar still set (the opening quote was never matched), it throws XamlParseException with SR.UnclosedQuote. System.Xaml throws this because an unterminated quoted string inside a markup extension leaves the token stream incomplete.","triggerScenarios":"XAML like `Text=\"{StaticResource 'Key}\"` or `Text=\"{Binding Path=\"Name\"}\"`-style mistakes where a quote opens a token in the extension but the matching close quote is missing before the extension terminator.","commonSituations":"Mixing outer XML attribute quotes with inner extension quotes of the same character; string-built XAML where a quote was dropped during concatenation; localized strings containing quotes pasted into extensions.","solutions":["Add the missing closing quote so each quote inside the braces is paired.","Use the opposite quote character inside the extension than the XML attribute uses (Text=\"{'Key'}\" vs Text='{\"Key\"}').","Replace problematic inline strings with x:Static or resource references.","Run the file through an XML/XAML editor that highlights unbalanced quotes."],"exampleFix":"<!-- before -->\n<TextBlock Text=\"{StaticResource 'Key}\" />\n\n<!-- after -->\n<TextBlock Text=\"{StaticResource 'Key'}\" />","handlingStrategy":"validation","validationCode":"static bool QuotesClosed(string value) { bool inS=false,inD=false; foreach (var c in value){ if(c=='\\'' && !inD) inS=!inS; else if(c=='\"' && !inS) inD=!inD; } return !inS && !inD; }","typeGuard":null,"tryCatchPattern":"try { return XamlReader.Parse(xaml); } catch (XamlParseException ex) { Log(\"Unclosed quote in XAML\", ex.LineNumber, ex.LinePosition); return null; }","preventionTips":["Pair every quote inside markup-extension values","Use &apos;/&quot; entities inside XML attributes","Prefer single quotes inside extensions when the attribute uses double quotes"],"tags":["xaml","markup-extension","unclosed-quote","parser"],"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-21T21:30:21.729Z"}