{"record":{"id":"48ff73dabaa8ea98","repo":"dotnet/maui","slug":"xc0040-48ff73","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/RowDefinitionCollectionTypeConverter.cs","lineNumber":43,"sourceCode":"\t\t\t\t{\n\t\t\t\t\tyield return Create(Dup);\n\t\t\t\t\tyield return Create(Ldc_I4, i);\n\t\t\t\t\tforeach (var instruction in gridlengthconverter.ConvertFromString(parts[i], context, node))\n\t\t\t\t\t\tyield return instruction;\n\t\t\t\t\tyield return Create(Newobj, module.ImportCtorReference(\n\t\t\t\t\t\t\tcontext.Cache,\n\t\t\t\t\t\t\ttype: (\"Microsoft.Maui.Controls\", \"Microsoft.Maui.Controls\", \"RowDefinition\"),\n\t\t\t\t\t\t\tparameterTypes: new[] { (\"Microsoft.Maui\", \"Microsoft.Maui\", \"GridLength\") }));\n\t\t\t\t\tyield return Create(Stelem_Ref);\n\t\t\t\t}\n\t\t\t\tyield return Create(Newobj, module.ImportCtorReference(\n\t\t\t\t\t\tcontext.Cache,\n\t\t\t\t\t\ttype: (\"Microsoft.Maui.Controls\", \"Microsoft.Maui.Controls\", \"RowDefinitionCollection\"),\n\t\t\t\t\t\tparamCount: 1));\n\t\t\t\tyield break;\n\n\t\t\t}\n\t\t\tthrow new BuildException(BuildExceptionCode.Conversion, node, null, value, typeof(RowDefinitionCollection));\n\t\t}\n\t}\n}","sourceCodeStart":25,"sourceCodeEnd":46,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledConverters/RowDefinitionCollectionTypeConverter.cs#L25-L46","documentation":"XC0040 Conversion thrown by RowDefinitionCollectionTypeConverter when the XAML string value is null or whitespace. The converter expects a comma-separated list of GridLength values (e.g. '*,Auto,100'). Note: if the value is non-empty but a segment is an invalid GridLength, the inner GridLengthTypeConverter throws its own XC0040 first; this throw at line 43 fires specifically for empty/whitespace input.","triggerScenarios":"Setting RowDefinitions to an empty string or whitespace-only value. Each segment must be a valid GridLength ('auto', '*', 'N*', or a number); invalid segments throw from GridLengthTypeConverter before reaching this line.","commonSituations":"An empty RowDefinitions attribute, or trailing commas producing empty segments that the inner GridLength converter rejects. Forgetting to provide row definitions while the property is set to an empty string.","solutions":["Provide a non-empty, comma-separated list of valid GridLength values (e.g. '*,Auto,100').","Remove trailing/leading commas that create empty segments.","Ensure each segment uses valid GridLength syntax: 'Auto', '*', 'N*', or a plain number."],"exampleFix":"<!-- before -->\n<Grid.RowDefinitions></Grid.RowDefinitions>\n\n<!-- after -->\n<Grid.RowDefinitions>\n  <RowDefinition Height=\"*\" />\n  <RowDefinition Height=\"Auto\" />\n</Grid.RowDefinitions>","handlingStrategy":"validation","validationCode":"// Validate a RowDefinitions XAML string before building\nstatic bool IsValidRowDefinitionCollection(string value)\n{\n    if (string.IsNullOrWhiteSpace(value)) return false;\n    foreach (var part in value.Split(','))\n    {\n        var v = part.Trim();\n        if (v.Equals(\"auto\", StringComparison.OrdinalIgnoreCase)) continue;\n        if (v == \"*\") continue;\n        if (v.EndsWith('*') &&\n            double.TryParse(v[..^1], NumberStyles.Number, CultureInfo.InvariantCulture, out _)) continue;\n        if (double.TryParse(v, NumberStyles.Number, CultureInfo.InvariantCulture, out _)) continue;\n        return false;\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Each comma-separated segment must be a valid GridLength ('Auto', '*', 'N*', or number).","Avoid trailing commas that create empty segments.","Prefer the element syntax (<RowDefinition Height=\"...\"/>) for clarity when possible."],"tags":["xaml","maui","xamlc","type-converter","rowdefinition","grid","build-time"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}