{"record":{"id":"adfd678c976afe0d","repo":"dotnet/wpf","slug":"sr-quotecharactersoutofplace","errorCode":null,"errorMessage":"SR.QuoteCharactersOutOfPlace","messagePattern":"SR\\.QuoteCharactersOutOfPlace","errorType":"exception","errorClass":"XamlParseException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs","lineNumber":466,"sourceCode":"                        break;\n                    case Comma:\n                        done = true;  // we are done.\n                        break;\n\n                    case EqualSign:\n                        _state = StringState.Property;\n                        done = true;  // we are done.\n                        break;\n\n                    case Backslash:\n                        escaped = true;\n                        break;\n\n                    case Quote1:\n                    case Quote2:\n                        if (!atStart)\n                        {\n                            throw new XamlParseException(this, SR.QuoteCharactersOutOfPlace);\n                        }\n\n                        quoteChar = ch;\n                        wasQuoted = true;\n                        break;\n\n                    default:  // All other character (including whitespace)\n                        if (_currentSpecialBracketCharacters is not null && _currentSpecialBracketCharacters.StartsEscapeSequence(ch))\n                        {\n                            Stack<char> bracketCharacterStack =\n                                _context.CurrentBracketModeParseParameters.BracketCharacterStack;\n                            bracketCharacterStack.Clear();\n                            bracketCharacterStack.Push(ch);\n                            _context.CurrentBracketModeParseParameters.IsBracketEscapeMode = true;\n                        }\n\n                        sb.Append(ch);\n                        break;","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs#L448-L484","documentation":"MeScanner.ReadString accepts quote characters (' or \") only at the start of a token inside a markup extension value. If a quote appears after token characters have been read (atStart == false), the scanner throws XamlParseException with SR.QuoteCharactersOutOfPlace, because mid-token quotes would make value/argument boundaries ambiguous.","triggerScenarios":"XAML values like `{StaticResource Ke'y}` or `{Binding Path=Na\"me}` where a quote character appears in the middle of an argument or after the first character of a value.","commonSituations":"Localized or user-supplied strings containing apostrophes placed directly inside markup extensions (e.g. `{StaticResource O'Brien}`); code-generated XAML not escaping quotes; attribute values quoted with the same character as the inner quote.","solutions":["Remove or reposition the quote so it only opens/closes the whole token, not the middle.","Wrap the whole value in quotes of the opposite kind, e.g. Text=\"{'literal with quote'}\" inside extension arguments.","Replace inline literal text with an XML entity (&apos; / &quot;) or a resource reference.","Escape the outer brace with {} if the content is literal and not a markup extension at all."],"exampleFix":"<!-- before -->\n<Label Content=\"{StaticResource O'Brien}\" />\n\n<!-- after -->\n<Label Content=\"{StaticResource O&apos;Brien}\" />","handlingStrategy":"validation","validationCode":"static bool HasMidTokenQuotes(string ext) { var inner = ext.Trim('{','}'); foreach (var tok in inner.Split(' ', ',')) { var t = tok.Trim(); if (t.Length > 1 && (t.StartsWith(\"'\") ^ t.EndsWith(\"'\"))) return false; } return true; }","typeGuard":null,"tryCatchPattern":"try { return XamlReader.Parse(xaml); } catch (XamlParseException ex) { HandleParseError(ex.LineNumber, ex.LinePosition); return null; }","preventionTips":["XML-escape quotes inside attribute values (&apos;, &quot;)","Use the opposite quote kind inside the extension vs the attribute","Route quoted user strings through resources"],"tags":["xaml","markup-extension","quote-escaping","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-22T01:17:13.364Z"}