{"record":{"id":"616523ee474ef669","repo":"dotnet/maui","slug":"xc0040-616523","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/BoundsTypeConverter.cs","lineNumber":19,"sourceCode":"using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing Microsoft.Maui.Controls.Build.Tasks;\nusing Microsoft.Maui.Controls.Xaml;\nusing Microsoft.Maui.Graphics;\nusing Mono.Cecil;\nusing Mono.Cecil.Cil;\n\nnamespace Microsoft.Maui.Controls.XamlC\n{\n\tclass BoundsTypeConverter : ICompiledTypeConverter\n\t{\n\t\tpublic IEnumerable<Instruction> ConvertFromString(string value, ILContext context, BaseNode node)\n\t\t{\n\t\t\tvar module = context.Body.Method.Module;\n\n\t\t\tif (string.IsNullOrEmpty(value))\n\t\t\t\tthrow new BuildException(BuildExceptionCode.Conversion, node, null, value, typeof(Rect));\n\n\t\t\tdouble x = -1, y = -1, w = -1, h = -1;\n\t\t\tbool hasX, hasY, hasW, hasH;\n\t\t\tvar xywh = value.Split(',');\n\n\t\t\tif (xywh.Length != 2 && xywh.Length != 4)\n\t\t\t\tthrow new BuildException(BuildExceptionCode.Conversion, node, null, value, typeof(Rect));\n\n\t\t\thasX = (xywh.Length == 2 || xywh.Length == 4) && double.TryParse(xywh[0], NumberStyles.Number, CultureInfo.InvariantCulture, out x);\n\t\t\thasY = (xywh.Length == 2 || xywh.Length == 4) && double.TryParse(xywh[1], NumberStyles.Number, CultureInfo.InvariantCulture, out y);\n\t\t\thasW = xywh.Length == 4 && double.TryParse(xywh[2], NumberStyles.Number, CultureInfo.InvariantCulture, out w);\n\t\t\thasH = xywh.Length == 4 && double.TryParse(xywh[3], NumberStyles.Number, CultureInfo.InvariantCulture, out h);\n\n\t\t\tif (!hasW && xywh.Length == 4 && string.Compare(\"AutoSize\", xywh[2].Trim(), StringComparison.OrdinalIgnoreCase) == 0)\n\t\t\t{\n\t\t\t\thasW = true;\n\t\t\t\tw = AbsoluteLayout.AutoSize;\n\t\t\t}","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledConverters/BoundsTypeConverter.cs#L1-L37","documentation":"XamlC error XC0040 from BoundsTypeConverter (used by AbsoluteLayout.LayoutBounds). An empty or null value is rejected immediately because a Bounds/Rect requires at least an x,y pair.","triggerScenarios":"LayoutBounds is set to an empty string or whitespace, e.g. LayoutBounds=\"\" left over in markup.","commonSituations":"An empty attribute left in XAML after editing; a binding/placeholder that resolved to empty; tooling inserting a blank value.","solutions":["Provide a valid bounds value such as '0,0' or '0,0,100,50'.","If no explicit bounds are needed, remove the LayoutBounds attribute entirely."],"exampleFix":"<!-- before -->\n<BoxView LayoutBounds=\"\" />\n\n<!-- after -->\n<BoxView LayoutBounds=\"0,0,100,50\" />","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave LayoutBounds empty; either set 'x,y' / 'x,y,w,h' or remove the attribute.","Run the XAML compiler (XamlC) in build so empty-value errors surface at compile time.","Avoid editor placeholders that resolve to empty strings."],"tags":["xaml","xamlc","layout","absolutelayout","compilation"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}