{"record":{"id":"bb537b4ddce60790","repo":"unoplatform/uno","slug":"value-must-either-be-null-or-of-type-bool-got-va-bb537b","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/FromNullableBoolToReverseBoolConverter.cs","lineNumber":22,"sourceCode":"using System.Text;\nusing Microsoft.UI.Xaml;\nusing Microsoft.UI.Xaml.Data;\nusing Microsoft.UI.Xaml.Media;\n\nnamespace Uno.UI.Samples.Converters\n{\n\tpublic class FromNullableBoolToReverseBoolConverter : IValueConverter\n\t{\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\tvar valueToConvert = value != null && System.Convert.ToBoolean(value, CultureInfo.InvariantCulture);\n\n\t\t\treturn !valueToConvert;\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}\n","sourceCodeStart":4,"sourceCodeEnd":36,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Converters/FromNullableBoolToReverseBoolConverter.cs#L4-L36","documentation":"FromNullableBoolToReverseBoolConverter.Convert throws when value is non-null and not a bool, enforcing the nullable-bool-only contract before inverting.","triggerScenarios":"Binding a non-bool source (int, enum, string, Visibility) to this reverse converter.","commonSituations":"Wrong binding path; source property type changed; value converter chain feeding an incompatible type.","solutions":["Bind to a bool / bool? source.","Pre-convert with another converter if the source is non-bool.","Check value.GetType().FullName in the message."],"exampleFix":"<!-- before -->\n{Binding Status, Converter={StaticResource Rev}}\n<!-- after -->\n{Binding IsActive, Converter={StaticResource Rev}}","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 only.","Use value.GetType().FullName from the message to diagnose."],"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"}