{"record":{"id":"8f4fc8bbdea8ba6c","repo":"dotnet/wpf","slug":"bracket-characters-cannot-be-one-of-the-following","errorCode":null,"errorMessage":"Bracket characters cannot be one of the following: '=' , ',', '\\'', '\\\"', '{ ', ' }', '\\\\'","messagePattern":"Bracket characters cannot be one of the following: '=' , ',', '\\\\'', '\\\\\"', '(.+?)', '\\\\\\\\'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Xaml/Parser/SpecialBracketCharacters.cs","lineNumber":84,"sourceCode":"                        _endCharactersStringBuilder.Append(closingBracket);\n                    }\n                }\n            }\n        }\n\n        private bool IsValidBracketCharacter(char openingBracket, char closingBracket)\n        {\n            if (openingBracket == closingBracket)\n            {\n                throw new InvalidOperationException(\"Opening bracket character cannot be the same as closing bracket character.\");\n            }\n            else if (char.IsLetterOrDigit(openingBracket) || char.IsLetterOrDigit(closingBracket) || char.IsWhiteSpace(openingBracket) || char.IsWhiteSpace(closingBracket))\n            {\n                throw new InvalidOperationException(\"Bracket characters cannot be alpha-numeric or whitespace.\");\n            }\n            else if (_restrictedCharSet.Contains(openingBracket) || _restrictedCharSet.Contains(closingBracket))\n            {\n                throw new InvalidOperationException(\"Bracket characters cannot be one of the following: '=' , ',', '\\'', '\\\"', '{ ', ' }', '\\\\'\");\n            }\n            else\n            {\n                return true;\n            }\n        }\n\n        internal bool IsSpecialCharacter(char ch)\n        {\n            return _startChars.Contains(ch.ToString()) || _endChars.Contains(ch.ToString());\n        }\n\n        internal bool StartsEscapeSequence(char ch)\n        {\n            return _startChars.Contains(ch.ToString());\n        }\n\n        internal bool EndsEscapeSequence(char ch)","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Xaml/Parser/SpecialBracketCharacters.cs#L66-L102","documentation":"IsValidBracketCharacter throws when either bracket character belongs to the restricted character set. The characters '=', ',', single quote, double quote, '{', '}', and backslash are already structurally significant in XAML markup, so allowing them as custom brackets would break parsing.","triggerScenarios":"Tokenize encounters a bracket dictionary containing any of: '=', ',', '\\'', '\"', '{', '}', '\\\\' as either the opening or closing character — e.g. trying to override or reuse '{' '}' as custom brackets.","commonSituations":"Developers attempting to redefine or augment the built-in curly-brace markup extension syntax, or building a delimiter scheme around quote/comma characters that XAML already reserves.","solutions":["Choose delimiter characters outside the restricted set, such as '[', ']', '<', '>', '|', or '#'","Remove any attempt to re-register '{' and '}' — they are already handled natively","Pre-screen the pair against the string \"=,'\\\"{}\\\\\" before adding"],"exampleFix":"// before\nparser.AddBracketCharacters('{', '}');\n// after\nparser.AddBracketCharacters('[', ']');","handlingStrategy":"validation","validationCode":"const string Restricted = \"=,'\\\"{}\\\\\";\nbool IsAllowed(char c) => !Restricted.Contains(c);","typeGuard":null,"tryCatchPattern":"try { tokenize(map); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"one of the following\")) { /* replace reserved chars in map */ }","preventionTips":["Never reuse XAML-reserved characters ({ } quotes comma equals backslash) as custom brackets","Pre-screen configured delimiters against the documented restricted set"],"tags":["wpf","xaml","validation"],"backgroundTag":"invalid-argument-value","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"}