{"record":{"id":"2435f11a9d932c6e","repo":"AvaloniaUI/Avalonia","slug":"invalid-fill-rule","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":201,"sourceCode":"\n            _geometryContext.BeginFigure(_currentPoint);\n\n            _beginFigurePoint = _currentPoint;\n\n            _isOpen = true;\n        }\n\n        private void SetFillRule(\n#if NET7SDK\n            scoped\n#endif\n            ref ReadOnlySpan<char> span)\n        {\n            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        }","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/PathMarkupParser.cs#L183-L219","documentation":"Thrown by SetFillRule when the fill-rule argument following an 'F' command is missing or not exactly one character. The parser expects exactly one char ('0' for EvenOdd, '1' for NonZero) immediately after F. ReadArgument returns false (end of string / no number) or the slice length is not 1, so the token cannot be interpreted as a fill rule.","triggerScenarios":"Path strings such as 'F' (no argument), 'F12' (two chars), or 'F ' followed by end of data. Also 'F0,1' where the parser reads a multi-char token.","commonSituations":"Hand-authoring SVG-style path data with an F command; copying a 'fill-rule' attribute value ('EvenOdd'/'NonZero') verbatim instead of the numeric 0/1 token this parser expects; truncating a path string mid-token.","solutions":["Use 'F0' for EvenOdd or 'F1' for NonZero, exactly one digit, no letters.","Place the F command at the start of the path before any figure commands.","Remove the F command entirely if you want the default fill rule (no fill-rule mutation)."],"exampleFix":"// before\ngeometry.Parse(\"FEvenOdd M0,0 L10,10 Z\");\n\n// after\ngeometry.Parse(\"F0 M0,0 L10,10 Z\");  // 0 = EvenOdd, 1 = NonZero","handlingStrategy":"validation","validationCode":"static bool HasValidFillRule(ReadOnlySpan<char> s)\n{\n    var i = 0;\n    while (i < s.Length && char.IsWhiteSpace(s[i])) i++;\n    return i < s.Length && (s[i] == '0' || s[i] == '1');\n}\n// before parsing, strip the F token and verify the next char is 0 or 1.","typeGuard":"static bool IsValidFillRuleChar(char c) => c is '0' or '1';","tryCatchPattern":"try { parser.Parse(data); }\ncatch (InvalidDataException ex) when (ex.Message.StartsWith(\"Invalid fill rule\"))\n{ /* report malformed F command to the user/data source */ }","preventionTips":["Use 'F0'/'F1' only; never the enum names.","Validate path strings coming from user input or external files before parsing."],"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"}