{"record":{"id":"5e930698bc23bcdb","repo":"dotnet/maui","slug":"cannot-convert-0-into-1-5e9306","errorCode":null,"errorMessage":"Cannot convert \"{0}\" into {1}","messagePattern":"Cannot convert \"(.+?)\" into (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/DoubleCollectionConverter.cs","lineNumber":32,"sourceCode":"\n\t\tpublic override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)\n\t\t\t=> destinationType == typeof(string);\n\n\t\tpublic override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)\n\t\t{\n\t\t\tif (value is double[] doublesArray)\n\t\t\t{\n\t\t\t\treturn (DoubleCollection)doublesArray;\n\t\t\t}\n\t\t\telse if (value is float[] floatsArray)\n\t\t\t{\n\t\t\t\treturn (DoubleCollection)floatsArray;\n\t\t\t}\n\n\t\t\tvar strValue = value.ToString();\n\t\t\tif (strValue is null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(string.Format(\"Cannot convert \\\"{0}\\\" into {1}\", strValue, typeof(DoubleCollection)));\n\t\t\t}\n\n\t\t\tstring[] doubles = strValue.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\tvar doubleCollection = new DoubleCollection();\n\n\t\t\tforeach (string d in doubles)\n\t\t\t{\n\t\t\t\tif (double.TryParse(d, NumberStyles.Number, CultureInfo.InvariantCulture, out double number))\n\t\t\t\t{\n\t\t\t\t\tdoubleCollection.Add(number);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tthrow new InvalidOperationException(string.Format(\"Cannot convert \\\"{0}\\\" into {1}\", d, typeof(double)));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn doubleCollection;","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/DoubleCollectionConverter.cs#L14-L50","documentation":"DoubleCollectionConverter.ConvertFrom throws InvalidOperationException when value.ToString() returns null. Because value is boxed object, ToString() normally yields a non-null string; reaching the null check requires a custom type whose ToString() returns null. The message formats the null and the DoubleCollection type.","triggerScenarios":"Passing an object whose ToString() override returns null to a DoubleCollection-typed property; binding a null-yielding source through the converter.","commonSituations":"Custom value types overriding ToString to return null; edge null-boxing paths.","solutions":["Pass a comma- or space-separated string of doubles (e.g. '1.5,2.5,3.5').","Ensure any source object's ToString() never returns null.","Pre-convert the source to a double[] or float[] which the converter also accepts."],"exampleFix":"// before\nvar dc = (DoubleCollection)converter.ConvertFrom(objWithNullToString);\n\n// after\nvar dc = (DoubleCollection)new[] { 1.5, 2.5 }; // accepted array path","handlingStrategy":"validation","validationCode":"var s = value?.ToString();\nif (s is null) throw new ArgumentException(\"value.ToString() is null; cannot convert to DoubleCollection.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass comma/space-separated double strings or double[]/float[].","Ensure source objects' ToString() never returns null.","Validate the string is non-null before assigning to DoubleCollection properties."],"tags":["typeconverter","doublecollection","convertfrom","invalidoperation"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}