{"record":{"id":"f98dfcc296c3eb91","repo":"dotnet/maui","slug":"xc0040-f98dfc","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/RectangleTypeConverter.cs","lineNumber":18,"sourceCode":"using 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 RectangleTypeConverter : 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\t\t\tdouble x, y, w, h;\n\t\t\tvar xywh = value.Split(',');\n\t\t\tif (xywh.Length != 4 ||\n\t\t\t\t!double.TryParse(xywh[0], NumberStyles.Number, CultureInfo.InvariantCulture, out x) ||\n\t\t\t\t!double.TryParse(xywh[1], NumberStyles.Number, CultureInfo.InvariantCulture, out y) ||\n\t\t\t\t!double.TryParse(xywh[2], NumberStyles.Number, CultureInfo.InvariantCulture, out w) ||\n\t\t\t\t!double.TryParse(xywh[3], NumberStyles.Number, CultureInfo.InvariantCulture, out h))\n\t\t\t\tthrow new BuildException(BuildExceptionCode.Conversion, node, null, value, typeof(Rect));\n\n\t\t\treturn GenerateIL(context, x, y, w, h, module);\n\t\t}\n\n\t\tIEnumerable<Instruction> GenerateIL(ILContext context, double x, double y, double w, double h, ModuleDefinition module)\n\t\t{\n\t\t\t//\t\t\tIL_0000:  ldc.r8 3.1000000000000001\n\t\t\t//\t\t\tIL_0009:  ldc.r8 4.2000000000000002\n\t\t\t//\t\t\tIL_0012:  ldc.r8 5.2999999999999998\n\t\t\t//\t\t\tIL_001b:  ldc.r8 6.4000000000000004","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledConverters/RectangleTypeConverter.cs#L1-L36","documentation":"XC0040 Conversion thrown by RectangleTypeConverter when the XAML string value is null or empty, before any parsing is attempted. This is the first guard in ConvertFromString for the Microsoft.Maui.Graphics.Rect type. The converter requires a non-empty, 4-part comma-separated string.","triggerScenarios":"Setting a Rect-typed property (e.g. a clip region or bounds) to an empty string or a value that the XAML compiler sees as null/empty. This is the specific empty-check throw, distinct from the format/parsing throw at line 26.","commonSituations":"An empty attribute value, a binding that resolves to empty at compile time, or accidentally leaving the attribute as an empty string.","solutions":["Provide a non-empty value in 'x,y,width,height' format with exactly 4 comma-separated invariant-culture doubles.","Remove the empty attribute if no value is needed.","If using a binding, ensure it produces a non-empty string."],"exampleFix":"<!-- before -->\n<Clip>\"\"</Clip>\n\n<!-- after -->\n<Clip>0,0,100,50</Clip>","handlingStrategy":"validation","validationCode":"// Validate that a Rect XAML string is non-empty before building\nstatic bool IsNonEmptyRectString(string value)\n    => !string.IsNullOrEmpty(value);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave a Rect-typed property as an empty string.","Remove the attribute entirely if no value is needed.","Ensure bindings that feed Rect properties produce non-empty strings."],"tags":["xaml","maui","xamlc","type-converter","rect","rectangle","build-time"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}