{"record":{"id":"ea224566d992dd26","repo":"dotnet/wpf","slug":"sr-glyphscaretstopscontainshexdigits","errorCode":null,"errorMessage":"SR.GlyphsCaretStopsContainsHexDigits","messagePattern":"SR\\.GlyphsCaretStopsContainsHexDigits","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Glyphs.cs","lineNumber":248,"sourceCode":"\n            bool[] caretStops = new bool[caretStopCount];\n\n            int i = 0;\n            foreach (char c in caretStopsString)\n            {\n                if (Char.IsWhiteSpace(c))\n                    continue;\n\n                int nibble;\n\n                if ('0' <= c && c <= '9')\n                    nibble = c - '0';\n                else if ('a' <= c && c <= 'f')\n                    nibble = c - 'a' + 10;\n                else if ('A' <= c && c <= 'F')\n                    nibble = c - 'A' + 10;\n                else\n                    throw new ArgumentException(SR.GlyphsCaretStopsContainsHexDigits, \"CaretStops\");\n\n                Debug.Assert(0 <= nibble && nibble <= 15);\n\n                if ((nibble & 8) != 0)\n                {\n                    if (i >= caretStops.Length)\n                        throw new ArgumentException(SR.GlyphsCaretStopsLengthCorrespondsToUnicodeString, \"CaretStops\");\n                    caretStops[i] = true;\n                }\n                ++i;\n                if ((nibble & 4) != 0)\n                {\n                    if (i >= caretStops.Length)\n                        throw new ArgumentException(SR.GlyphsCaretStopsLengthCorrespondsToUnicodeString, \"CaretStops\");\n                    caretStops[i] = true;\n                }\n                ++i;\n                if ((nibble & 2) != 0)","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Glyphs.cs#L230-L266","documentation":"Glyphs.ParseCaretStops validates the CaretStops string, which must contain only hex digits (0-9, a-f, A-F). Any other character makes the caret-stop bitmap unparseable, so an ArgumentException is thrown naming the CaretStops property.","triggerScenarios":"Setting Glyphs.CaretStops (typically via XAML) to a string containing a non-hex character, e.g. spaces, 'g'-'z', punctuation, or sign characters.","commonSituations":"Hand-edited XAML where CaretStops was typo'd; programmatic string building that inserted separators like commas or spaces between hex groups.","solutions":["Replace every non-hex character in the CaretStops string with a valid hex digit","Remove separators/spaces between hex groups","Validate the string with a regex before assigning it"],"exampleFix":"// before\nCaretStops = \"00F0 0FF0\";\n// after\nCaretStops = \"00F00FF0\";","handlingStrategy":"validation","validationCode":"bool ok = string.IsNullOrEmpty(caretStops) || System.Text.RegularExpressions.Regex.IsMatch(caretStops, \"^[0-9a-fA-F]*$\");\nif (!ok) throw new ArgumentException(\"CaretStops must be hex digits only\");","typeGuard":null,"tryCatchPattern":"try { glyphs.CaretStops = value; } catch (ArgumentException) { /* sanitize to hex and retry */ }","preventionTips":["Regex-validate hex-only before assignment","Never insert spaces/commas into CaretStops","Build CaretStops with string.Format(\"{0:X}\", bits) style code"],"tags":["wpf","glyphs","xaml-parsing"],"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"}