{"record":{"id":"cd8aa7f99d7b053f","repo":"AvaloniaUI/Avalonia","slug":"invalid-cornerradius","errorCode":null,"errorMessage":"Invalid CornerRadius.","messagePattern":"Invalid CornerRadius\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/CornerRadius.cs","lineNumber":114,"sourceCode":"\n            using (var tokenizer = new SpanStringTokenizer(s, CultureInfo.InvariantCulture, exceptionMessage))\n            {\n                if (tokenizer.TryReadDouble(out var a))\n                {\n                    if (tokenizer.TryReadDouble(out var b))\n                    {\n                        if (tokenizer.TryReadDouble(out var c))\n                        {\n                            return new CornerRadius(a, b, c, tokenizer.ReadDouble());\n                        }\n\n                        return new CornerRadius(a, b);\n                    }\n\n                    return new CornerRadius(a);\n                }\n\n                throw new FormatException(exceptionMessage);\n            }\n        }\n\n        public static bool operator ==(CornerRadius left, CornerRadius right)\n        {\n            return left.Equals(right);\n        }\n\n        public static bool operator !=(CornerRadius left, CornerRadius right)\n        {\n            return !(left == right);\n        }\n    }\n}\n","sourceCodeStart":96,"sourceCodeEnd":129,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/CornerRadius.cs#L96-L129","documentation":"Thrown as FormatException by CornerRadius.Parse(string) when the input string cannot be tokenized into 1–4 double values (uniform, top-left/bottom-right, or four-corner). Parse uses an invariant-culture SpanStringTokenizer and the message 'Invalid CornerRadius.' is the constant exceptionMessage.","triggerScenarios":"Calling CornerRadius.Parse(s) where s is empty, contains non-numeric text, has too many tokens, or uses the wrong decimal separator for invariant culture (e.g., a comma where a period is expected, or locale-specific formatting). Also thrown when the first token read fails entirely (line 114).","commonSituations":"XAML or code passes a malformed CornerRadius string like \"abc\", \"1,,2\", \"1;2\", or a locale-formatted value using comma decimals. Binding a CornerRadius from a string source with wrong formatting. Deserialization of CornerRadius from user input.","solutions":["Provide a valid CornerRadius string: one value (\"5\"), two (\"5,10\"), or four (\"5,10,5,10\") doubles separated by commas or spaces, using invariant period decimals.","If the source is locale-dependent, normalize/replace separators before parsing or use the CornerRadius(double) constructors directly.","Validate with double.TryParse on each token before calling Parse, or wrap Parse in try/catch FormatException."],"exampleFix":"// before\nvar c = CornerRadius.Parse(\"1;2\"); // throws\n// after\nvar c = CornerRadius.Parse(\"1,2\"); // or new CornerRadius(1, 2)","handlingStrategy":"try-catch","validationCode":"if (!CornerRadius.TryParseInvariant(s, out var corner))\n    throw new FormatException($\"Invalid CornerRadius: '{s}'\");","typeGuard":null,"tryCatchPattern":"try { var c = CornerRadius.Parse(s); }\ncatch (FormatException) { c = default; // or log }","preventionTips":["Use invariant-culture comma-separated doubles for CornerRadius strings.","Validate user-supplied strings before Parse.","Prefer the CornerRadius(double...) constructors in code over string parsing."],"tags":["cornerradius","parse","format","xaml"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}