{"record":{"id":"47933720ea78651c","repo":"dotnet/maui","slug":"xc0040-479337","errorCode":"XC0040","errorMessage":"Cannot convert value \"{0}\" to \"{1}\".","messagePattern":"Cannot convert value \"(.+?)\" to \"(.+?)\"\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/CompiledConverters/StrokeShapeTypeConverter.cs","lineNumber":213,"sourceCode":"\t\t\t\tyield return Instruction.Create(OpCodes.Newobj, module.ImportCtorReference(context.Cache, (\"Microsoft.Maui.Controls\", \"Microsoft.Maui.Controls.Shapes\", \"Rectangle\"), parameterTypes: null));\n\t\t\t\tyield return Instruction.Create(OpCodes.Dup);\n\n\t\t\t\tyield return Instruction.Create(OpCodes.Ldc_R8, radius);\n\t\t\t\tyield return Instruction.Create(OpCodes.Ldc_R8, radius);\n\t\t\t\tyield return Instruction.Create(OpCodes.Ldc_R8, radius);\n\t\t\t\tyield return Instruction.Create(OpCodes.Ldc_R8, radius);\n\n\t\t\t\tyield return Instruction.Create(OpCodes.Newobj, module.ImportCtorReference(context.Cache, (\"Microsoft.Maui\", \"Microsoft.Maui\", \"CornerRadius\"), parameterTypes: new[] {\n\t\t\t\t\t(\"mscorlib\", \"System\", \"Double\"),\n\t\t\t\t\t(\"mscorlib\", \"System\", \"Double\"),\n\t\t\t\t\t(\"mscorlib\", \"System\", \"Double\"),\n\t\t\t\t\t(\"mscorlib\", \"System\", \"Double\")}));\n\n\t\t\t\tyield return Instruction.Create(OpCodes.Call, module.ImportPropertySetterReference(context.Cache, (\"Microsoft.Maui.Controls\", \"Microsoft.Maui.Controls.Shapes\", \"RoundRectangle\"), \"CornerRadius\"));\n\t\t\t\tyield break;\n\t\t\t}\n\t\t}\n\t\tthrow new BuildException(BuildExceptionCode.Conversion, node, null, value, typeof(IShape));\n\t}\n\n\tIEnumerable<Instruction> CreatePointCollection(ILContext context, ModuleDefinition module, PointCollection points)\n\t{\n\t\tvar pointType = module.ImportReference(context.Cache, (\"Microsoft.Maui.Graphics\", \"Microsoft.Maui.Graphics\", \"Point\"));\n\t\tyield return Instruction.Create(OpCodes.Ldc_I4, points.Count);\n\t\tyield return Instruction.Create(OpCodes.Newarr, pointType);\n\n\t\tvar pointTypeConverter = new PointTypeConverter();\n\t\tfor (int i = 0; i < points.Count; i++)\n\t\t{\n\t\t\tyield return Instruction.Create(OpCodes.Dup);\n\t\t\tyield return Instruction.Create(OpCodes.Ldc_I4, i);\n\n\t\t\tforeach (var instruction in pointTypeConverter.CreatePoint(context, module, points[i]))\n\t\t\t{\n\t\t\t\tyield return instruction;\n\t\t\t}","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledConverters/StrokeShapeTypeConverter.cs#L195-L231","documentation":"XC0040 Conversion thrown by StrokeShapeTypeConverter when the XAML string does not match any recognized shape keyword and is not a plain number. Recognized keywords (case-sensitive StartsWith) are: Ellipse, Line, Path, Polygon, Polyline, Rectangle, RoundRectangle. A plain number is interpreted as a uniform corner radius for a RoundRectangle. If none match, the build fails with target type IShape.","triggerScenarios":"Setting Border.StrokeShape or a Shape property to an unrecognized shape name, a misspelled keyword, or empty/whitespace. Examples: 'RoundRectangle ' (empty after keyword is handled differently), 'Circle' (should be 'Ellipse'), 'Triangle' (not a built-in shape — use Path or Polygon), 'roundrect' (case-sensitive prefix).","commonSituations":"Using 'Circle' instead of 'Ellipse'. Using lowercase shape names ('roundrectangle' vs 'RoundRectangle'). Forgetting to include any shape keyword. The value is case-sensitive — the converter uses StartsWith with Ordinal comparison.","solutions":["Use one of the recognized shape keywords: Ellipse, Line, Path, Polygon, Polyline, Rectangle, or RoundRectangle (case-sensitive).","For RoundRectangle with a corner radius, use 'RoundRectangle CornerRadius' syntax or a plain number for uniform radius.","Ensure the keyword prefix matches exactly (uppercase first letter as shown)."],"exampleFix":"<!-- before -->\n<Border StrokeShape=\"Circle\" />\n\n<!-- after -->\n<Border StrokeShape=\"Ellipse\" />\n<!-- or -->\n<Border StrokeShape=\"RoundRectangle 10\" />","handlingStrategy":"validation","validationCode":"// Validate a StrokeShape XAML string before building\nstatic readonly string[] ValidShapePrefixes =\n    { \"Ellipse\", \"Line\", \"Path\", \"Polygon\", \"Polyline\", \"Rectangle\", \"RoundRectangle\" };\nstatic bool IsValidStrokeShape(string value)\n{\n    if (string.IsNullOrWhiteSpace(value)) return false;\n    value = value.Trim();\n    if (ValidShapePrefixes.Any(p => value.StartsWith(p, StringComparison.Ordinal)))\n        return true;\n    return double.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out _);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exact shape keywords with correct casing: Ellipse, Line, Path, Polygon, Polyline, Rectangle, RoundRectangle.","There is no 'Circle' shape — use 'Ellipse' instead.","A plain number is treated as a uniform corner radius for a RoundRectangle."],"tags":["xaml","maui","xamlc","type-converter","shape","strokeshape","border","build-time"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}