{"record":{"id":"42fab94b3bca6a55","repo":"AvaloniaUI/Avalonia","slug":"invalid-fill-rule-42fab9","errorCode":null,"errorMessage":"Invalid fill rule","messagePattern":"Invalid fill rule","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/PathMarkupParser.cs","lineNumber":215,"sourceCode":"            ThrowIfDisposed();\n\n            if (!ReadArgument(ref span, out var fillRule) || fillRule.Length != 1)\n            {\n                throw new InvalidDataException(\"Invalid fill rule.\");\n            }\n\n            FillRule rule;\n\n            switch (fillRule[0])\n            {\n                case '0':\n                    rule = FillRule.EvenOdd;\n                    break;\n                case '1':\n                    rule = FillRule.NonZero;\n                    break;\n                default:\n                    throw new InvalidDataException(\"Invalid fill rule\");\n            }\n\n            _geometryContext.SetFillRule(rule);\n        }\n\n        private void CloseFigure()\n        {\n            ThrowIfDisposed();\n\n            if (_isOpen)\n            {\n                _geometryContext.EndFigure(true);\n\n                if (_beginFigurePoint != null)\n                {\n                    _currentPoint = _beginFigurePoint.Value;\n                    _beginFigurePoint = null;\n                }","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/PathMarkupParser.cs#L197-L233","documentation":"Thrown by SetFillRule's inner switch when the single fill-rule character is neither '0' nor '1'. The token was read successfully and is exactly one character long, but that character is something else (a letter, a digit other than 0/1, or punctuation).","triggerScenarios":"Path strings like 'F2', 'Fx', 'F ' where the single char is not 0 or 1.","commonSituations":"Typing 'F2' or using a locale-specific flag; confusing the numeric fill-rule token with the enum name; stray whitespace captured as the token.","solutions":["Use 'F0' (EvenOdd) or 'F1' (NonZero) only.","Double-check there is no stray character between F and the digit (e.g. 'F:0').","If you do not need to change the fill rule, omit the F command."],"exampleFix":"// before\ngeometry.Parse(\"F2 M0,0 L10,10 Z\");\n\n// after\ngeometry.Parse(\"F1 M0,0 L10,10 Z\");  // NonZero","handlingStrategy":"validation","validationCode":"var fillChar = /* the single char after 'F' */;\nif (fillChar is not ('0' or '1')) throw /* or sanitize */;","typeGuard":"static bool IsValidFillRuleChar(char c) => c is '0' or '1';","tryCatchPattern":"try { parser.Parse(data); }\ncatch (InvalidDataException ex) when (ex.Message == \"Invalid fill rule\")\n{ /* the F token's char was not 0/1 */ }","preventionTips":["Whitelist the fill-rule character to '0' or '1'.","Avoid generating F tokens programmatically with arbitrary enum indices."],"tags":["avalonia","path-markup","fill-rule","invalid-data","parse"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}