{"record":{"id":"0df98ebcb320245b","repo":"dotnet/maui","slug":"property","errorCode":null,"errorMessage":"property","messagePattern":"property","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/BindableObject.cs","lineNumber":86,"sourceCode":"\t\t/// Occurs when a property value is changing.\n\t\t/// </summary>\n\t\tpublic event PropertyChangingEventHandler PropertyChanging;\n\n\t\t/// <summary>\n\t\t/// Occurs when the value of the <see cref=\"BindingContext\"/> property changes.\n\t\t/// </summary>\n\t\tpublic event EventHandler BindingContextChanged;\n\n\t\t/// <summary>\n\t\t/// Clears any value that is previously set for a bindable property.\n\t\t/// </summary>\n\t\t/// <param name=\"property\">The <see cref=\"BindableProperty\"/> to clear the value for.</param>\n\t\t/// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"property\"/> is <see langword=\"null\"/>.</exception>\n\t\t/// <remarks>When <paramref name=\"property\"/> is read-only, nothing will happen.</remarks>\n\t\tpublic void ClearValue(BindableProperty property)\n\t\t{\n\t\t\tif (property == null)\n\t\t\t\tthrow new ArgumentNullException(nameof(property));\n\n\t\t\tif (property.IsReadOnly)\n\t\t\t{\n\t\t\t\tApplication.Current?.FindMauiContext()?.CreateLogger<BindableObject>()?.LogWarning($\"Cannot set the BindableProperty \\\"{property.PropertyName}\\\" because it is readonly.\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tClearValueCore(property, SetterSpecificity.ManualValueSetter);\n\t\t}\n\n\t\tinternal void ClearValue(BindableProperty property, SetterSpecificity specificity)\n\t\t{\n\t\t\tif (property == null)\n\t\t\t\tthrow new ArgumentNullException(nameof(property));\n\n\t\t\tif (property.IsReadOnly)\n\t\t\t{\n\t\t\t\tApplication.Current?.FindMauiContext()?.CreateLogger<BindableObject>()?.LogWarning($\"Cannot set the BindableProperty \\\"{property.PropertyName}\\\" because it is readonly.\");","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/BindableObject.cs#L68-L104","documentation":"Thrown by the public BindableObject.ClearValue(BindableProperty) overload when the property argument is null. The method guards its precondition up front because every subsequent step (IsReadOnly check, ClearValueCore) needs a real BindableProperty to key the value store.","triggerScenarios":"Calling ClearValue(null) or ClearValue(someExpression) where the expression evaluates to null, hitting 'if (property == null) throw new ArgumentNullException(nameof(property))'.","commonSituations":"Passing a BindableProperty field that was never initialized or was nulled out; computing the property from a dictionary/lookup that can return null; clearing inside a generic helper where T's property resolver returned null.","solutions":["Pass a concrete, non-null BindableProperty reference (e.g. Label.TextProperty).","Null-check before calling: if (property is not null) obj.ClearValue(property);.","Fix the resolver/lookup that produced the null BindableProperty so it always returns a valid field."],"exampleFix":"// before\nobj.ClearValue(maybeNullProperty);\n// after\nif (maybeNullProperty is not null) obj.ClearValue(maybeNullProperty);","handlingStrategy":"validation","validationCode":"static void SafeClear(BindableObject obj, BindableProperty? p)\n{\n    if (p is null) return;\n    obj.ClearValue(p);\n}","typeGuard":"static bool IsValidProperty(BindableProperty? p) => p is not null;","tryCatchPattern":null,"preventionTips":["Pass concrete BindableProperty fields (e.g. Label.TextProperty), never computed nulls.","Null-check before ClearValue when the property source may be absent.","Review generic helpers that resolve BindableProperty to ensure they never return null."],"tags":["bindable-object","null-argument","clearvalue"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}