{"record":{"id":"a842f8b1c709ffc7","repo":"AvaloniaUI/Avalonia","slug":"invalid-double-value","errorCode":null,"errorMessage":"Invalid double value","messagePattern":"Invalid double value","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/PathMarkupParser.cs","lineNumber":561,"sourceCode":"            \n            span = span.Slice(1);\n            \n            switch (c)\n            {\n                case '0':\n                    return false;\n                case '1':\n                    return true;\n                default:\n                    throw new InvalidDataException(\"Invalid bool rule\");\n            }\n        }\n\n        private static double ReadDouble(ref ReadOnlySpan<char> span)\n        {\n            if (!ReadArgument(ref span, out var doubleValue))\n            {\n                throw new InvalidDataException(\"Invalid double value\");\n            }\n\n            return double.Parse(doubleValue.ToString(), CultureInfo.InvariantCulture);\n        }\n\n        private static Size ReadSize(ref ReadOnlySpan<char> span)\n        {\n            var width = ReadDouble(ref span);\n            span = ReadSeparator(span);\n            var height = ReadDouble(ref span);\n            return new Size(width, height);\n        }\n\n        private static Point ReadPoint(ref ReadOnlySpan<char> span)\n        {\n            var x = ReadDouble(ref span);\n            span = ReadSeparator(span);\n            var y = ReadDouble(ref span);","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/PathMarkupParser.cs#L543-L579","documentation":"Thrown by ReadDouble when ReadArgument could not extract a valid numeric token from the span. ReadArgument validates an optional leading '-', integer digits, an optional '.', fractional digits, and optional scientific notation; if none of those form a valid number, ReadArgument returns false and ReadDouble throws. This affects every numeric coordinate, size, and angle in the path.","triggerScenarios":"Any command whose numeric argument is missing, empty, or non-numeric, e.g. 'M x,y' (letters), 'L' followed by end of string, 'H,' (comma with no number), or 'C1,1,1,1,' (trailing separator with no value).","commonSituations":"Truncated path strings; stray commas/semicolons instead of expected numbers; localized number formatting using ',' as decimal separator bleeding into a comma-separated coordinate list; copy-paste dropping digits.","solutions":["Ensure every numeric argument is a well-formed number using '.' as the decimal separator and invariant culture.","Remove trailing separators and empty tokens from the path string.","If you use ',' as a decimal separator in your locale, convert to '.' (and use ' ' or ',' as the coordinate separator per SVG path grammar) before parsing."],"exampleFix":"// before (locale comma as decimal, plus stray comma)\ngeometry.Parse(\"M0,0 L10,5,5,0\");\n\n// after\ngeometry.Parse(\"M0,0 L10,5 5,0\");","handlingStrategy":"validation","validationCode":"static bool AllNumbersWellFormed(string path)\n{\n    // split on command letters/separators and double.TryParse each token\n    // with CultureInfo.InvariantCulture; reject empties/non-numbers.\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try { parser.Parse(data); }\ncatch (InvalidDataException ex) when (ex.Message == \"Invalid double value\")\n{ /* report which numeric token is malformed */ }","preventionTips":["Generate numbers with CultureInfo.InvariantCulture ('.' decimal separator).","Trim trailing separators; never leave an empty token after a comma.","Validate externally sourced path data before handing it to Parse()."],"tags":["avalonia","path-markup","number","invalid-data","parse","localization"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}