{"record":{"id":"0c966f2e6db5ee5c","repo":"unoplatform/uno","slug":"value-must-either-be-null-or-of-type-bool-got-va-0c966f","errorCode":null,"errorMessage":"Value must either be null or of type bool. Got {value} ({value.GetType().FullName})","messagePattern":"Value must either be null or of type bool\\. Got (.+?) \\((.+?)\\)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Converters/FromNullableBoolToDefaultValueConverter.cs","lineNumber":25,"sourceCode":"using Microsoft.UI.Xaml.Media;\n\nnamespace Uno.UI.Samples.Converters\n{\n\tpublic class FromNullableBoolToDefaultValueConverter : IValueConverter\n\t{\n\t\tpublic object NullOrFalseValue { get; set; }\n\t\tpublic object TrueValue { get; set; }\n\n\t\tpublic object Convert(object value, Type targetType, object parameter, string language)\n\t\t{\n\t\t\tif (parameter != null)\n\t\t\t{\n\t\t\t\tthrow new ArgumentException($\"This converter does not use any parameters. You should remove \\\"{parameter}\\\" passed as parameter.\");\n\t\t\t}\n\n\t\t\tif (value != null && !(value is bool))\n\t\t\t{\n\t\t\t\tthrow new ArgumentException($\"Value must either be null or of type bool. Got {value} ({value.GetType().FullName})\");\n\t\t\t}\n\n\t\t\tif (value == null || !System.Convert.ToBoolean(value, CultureInfo.InvariantCulture))\n\t\t\t{\n\t\t\t\treturn NullOrFalseValue;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn TrueValue;\n\t\t\t}\n\t\t}\n\n\t\tpublic object ConvertBack(object value, Type targetType, object parameter, string language)\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\t}\n}","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Converters/FromNullableBoolToDefaultValueConverter.cs#L7-L43","documentation":"Same design as error 106 in the unit-test converter: Convert throws when value is non-null and not a bool. The test converter only accepts null or bool to keep bindings type-safe.","triggerScenarios":"The test binds a non-bool, non-null source (int, string, Visibility) to this converter.","commonSituations":"Test fixture bound to the wrong property; value type changed without updating the test binding.","solutions":["Bind to a bool or bool? source in the test.","Insert an intermediate converter if the source is non-bool by design.","Read value.GetType().FullName from the message to find the unexpected type."],"exampleFix":"<!-- before -->\n{Binding ItemCount, Converter={StaticResource Def}}\n<!-- after -->\n{Binding HasItems, Converter={StaticResource Def}}","handlingStrategy":"type-guard","validationCode":"if (value is not null and not bool) throw new ArgumentException(\"expected bool?\");","typeGuard":"static bool IsNullableBool(object value) => value is null or bool;","tryCatchPattern":null,"preventionTips":["Bind bool / bool? sources to nullable-bool converters in tests.","Inspect value.GetType().FullName from the message to find the wrong type."],"tags":["xaml","binding","converter","type-mismatch","unit-tests","samples"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}