{"record":{"id":"4e7787ceb2908562","repo":"AvaloniaUI/Avalonia","slug":"could-not-parse-specified-unicode-range","errorCode":null,"errorMessage":"Could not parse specified Unicode range.","messagePattern":"Could not parse specified Unicode range\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/UnicodeRange.cs","lineNumber":77,"sourceCode":"                {\n                    return true;\n                }\n            }\n\n            return false;\n        }\n\n        /// <summary>\n        /// Parses a <see cref=\"UnicodeRange\"/>.\n        /// </summary>\n        /// <param name=\"s\">The string to parse.</param>\n        /// <returns>The parsed <see cref=\"UnicodeRange\"/>.</returns>\n        /// <exception cref=\"FormatException\"></exception>\n        public static UnicodeRange Parse(string s)\n        {\n            if (string.IsNullOrEmpty(s))\n            {\n                throw new FormatException(\"Could not parse specified Unicode range.\");\n            }\n\n            var parts = s.Split(',');\n\n            var length = parts.Length;\n\n            if(length == 0)\n            {\n                throw new FormatException(\"Could not parse specified Unicode range.\");\n            }\n\n            if(length == 1)\n            {\n                return new UnicodeRange(UnicodeRangeSegment.Parse(parts[0]));\n            }\n\n            var segments = new UnicodeRangeSegment[length];\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/UnicodeRange.cs#L59-L95","documentation":"Thrown by UnicodeRange.Parse when the input string s is null or empty. UnicodeRange.Parse expects a comma-separated list of range segments (e.g. 'U+20-7F, U+100'). An empty/null input has no segments to parse and is rejected with a FormatException.","triggerScenarios":"Calling UnicodeRange.Parse(null) or UnicodeRange.Parse(\"\"). This is the first guard in Parse, before splitting on commas. The identical message is reused at line 86 for a different (defensive) condition.","commonSituations":"Deserializing a unicode-range from CSS/config where the field is absent and resolves to null/empty; passing an unset property; a binding that did not resolve.","solutions":["Provide a non-empty unicode-range string such as 'U+0000-007F'.","Guard the call: if (string.IsNullOrEmpty(s)) return UnicodeRange.AllRanges (or a sensible default) instead of calling Parse.","Ensure the data source always supplies a value."],"exampleFix":"// before\nvar range = UnicodeRange.Parse(value); // throws when value is null/empty\n\n// after\nvar range = string.IsNullOrEmpty(value) ? UnicodeRange.AllRanges : UnicodeRange.Parse(value);","handlingStrategy":"validation","validationCode":"static UnicodeRange SafeParseRange(string s)\n    => string.IsNullOrEmpty(s) ? UnicodeRange.AllRanges : UnicodeRange.Parse(s);","typeGuard":null,"tryCatchPattern":"try { return UnicodeRange.Parse(s); }\ncatch (FormatException) { return UnicodeRange.AllRanges; }","preventionTips":["Coalesce null/empty unicode-range strings to a full-range default.","Validate config/binding values are present before parsing.","Treat external unicode-range input as untrusted."],"tags":["unicode","parse","format-exception","avalonia"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}