{"record":{"id":"9796b57e8fca679e","repo":"dotnet/maui","slug":"xc0040-9796b5","errorCode":"XC0040","errorMessage":"Cannot convert value \"{0}\" to \"{1}\".","messagePattern":"Cannot convert value \"(.+?)\" to \"(.+?)\"\\.","errorType":"error_code","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/CompiledConverters/CornerRadiusTypeConverter.cs","lineNumber":36,"sourceCode":"\t\t\t{\n\t\t\t\tdouble l, tl, tr, bl, br;\n\t\t\t\tvar cornerradius = value.Split(',');\n\t\t\t\tswitch (cornerradius.Length)\n\t\t\t\t{\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tif (double.TryParse(cornerradius[0], NumberStyles.Number, CultureInfo.InvariantCulture, out l))\n\t\t\t\t\t\t\treturn GenerateIL(context, module, l);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 4:\n\t\t\t\t\t\tif (double.TryParse(cornerradius[0], NumberStyles.Number, CultureInfo.InvariantCulture, out tl)\n\t\t\t\t\t\t\t&& double.TryParse(cornerradius[1], NumberStyles.Number, CultureInfo.InvariantCulture, out tr)\n\t\t\t\t\t\t\t&& double.TryParse(cornerradius[2], NumberStyles.Number, CultureInfo.InvariantCulture, out bl)\n\t\t\t\t\t\t\t&& double.TryParse(cornerradius[3], NumberStyles.Number, CultureInfo.InvariantCulture, out br))\n\t\t\t\t\t\t\treturn GenerateIL(context, module, tl, tr, bl, br);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new BuildException(BuildExceptionCode.Conversion, node, null, value, typeof(CornerRadius));\n\t\t}\n\n\t\tIEnumerable<Instruction> GenerateIL(ILContext context, ModuleDefinition module, params double[] args)\n\t\t{\n\t\t\tforeach (var d in args)\n\t\t\t\tyield return Instruction.Create(OpCodes.Ldc_R8, d);\n\t\t\tyield return Instruction.Create(OpCodes.Newobj, module.ImportCtorReference(context.Cache, (\"Microsoft.Maui\", \"Microsoft.Maui\", \"CornerRadius\"), parameterTypes: args.Select(a => (\"mscorlib\", \"System\", \"Double\")).ToArray()));\n\t\t}\n\t}\n\n}\n","sourceCodeStart":18,"sourceCodeEnd":48,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledConverters/CornerRadiusTypeConverter.cs#L18-L48","documentation":"XC0040 Conversion thrown by CornerRadiusTypeConverter when a XAML string value cannot be parsed into a Microsoft.Maui.CornerRadius during XAML compilation. The converter splits the string on commas and accepts exactly 1 value (uniform radius) or 4 values (top-left, top-right, bottom-left, bottom-right), each parsed as an invariant-culture double. If the split yields a count other than 1 or 4, or any segment fails double.TryParse, the exception fires.","triggerScenarios":"Setting CornerRadius (e.g. on a Border, Frame, or RoundRectangle shape) to a comma-separated string with 2 or 3 segments, a non-numeric segment, or using a locale-specific decimal separator. Example: CornerRadius=\"10,20\" (only 2 values), CornerRadius=\"1,2,3\" (3 values), CornerRadius=\"1.5x,2\" (typo).","commonSituations":"Developers confuse CornerRadius (1 or 4 values) with Thickness (1, 2, or 4 values) and write two-value shorthand like '10,20'. Using a comma decimal separator in a non-invariant locale does not cause issues (InvariantCulture is used) but spaces inside segments like '1 0, 2 0' will. Copying CSS-style values or mixing up corner order with Thickness order.","solutions":["Provide exactly 1 value for a uniform radius or exactly 4 comma-separated values in order: topLeft, topRight, bottomLeft, bottomRight.","Remove any non-numeric characters, spaces inside segments, or stray delimiters from the value.","If you need different horizontal/vertical radii, note that CornerRadius does not support that shape — use 4 corner values instead."],"exampleFix":"<!-- before -->\n<Border StrokeShape=\"RoundRectangle 10,20\">\n  <Border.CornerRadius>10,20</Border.CornerRadius>\n</Border>\n\n<!-- after -->\n<Border StrokeShape=\"RoundRectangle 10,10,10,10\">\n  <Border.CornerRadius>10,20,10,20</Border.CornerRadius>\n</Border>","handlingStrategy":"validation","validationCode":"// Validate a CornerRadius XAML string before building\nstatic bool IsValidCornerRadius(string value)\n{\n    if (string.IsNullOrWhiteSpace(value)) return false;\n    var parts = value.Trim().Split(',');\n    if (parts.Length != 1 && parts.Length != 4) return false;\n    return parts.All(p => double.TryParse(p.Trim(), NumberStyles.Number, CultureInfo.InvariantCulture, out _));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember CornerRadius accepts only 1 (uniform) or 4 (TL,TR,BL,BR) comma-separated values — never 2 or 3.","Use invariant-culture formatting (dot decimal separator) when generating CornerRadius values programmatically.","Add a pre-build XAML validation step or linter that checks comma-count for known multi-value properties."],"tags":["xaml","maui","xamlc","type-converter","cornerradius","build-time"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}