{"record":{"id":"d0fe00edff894709","repo":"dotnet/maui","slug":"targetproperty","errorCode":null,"errorMessage":"targetProperty","messagePattern":"targetProperty","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/BindableObject.cs","lineNumber":248,"sourceCode":"\t\t\t\t{\n\t\t\t\t\tvar pair = context.Values.GetSpecificityAndValue();\n\t\t\t\t\tresult.IsSet = pair.Key != SetterSpecificity.DefaultValue;\n\t\t\t\t\tresult.Value = (T)pair.Value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn resultArray;\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Determines whether or not a bindable property exists and has a value set.\n\t\t/// </summary>\n\t\t/// <param name=\"targetProperty\">The bindable property to check if a value is currently set.</param>\n\t\t/// <returns><see langword=\"true\"/> if the target property exists and has been set. Otherwise <see langword=\"false\"/>.</returns>\n\t\t/// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"targetProperty\"/> is <see langword=\"null\"/>.</exception>\n\t\tpublic bool IsSet(BindableProperty targetProperty)\n\t\t{\n\t\t\tvar bpcontext = GetContext(targetProperty ?? throw new ArgumentNullException(nameof(targetProperty)));\n\t\t\tif (bpcontext == null)\n\t\t\t\treturn false;\n\t\t\tif ((bpcontext.Attributes & BindableContextAttributes.IsDefaultValueCreated) == BindableContextAttributes.IsDefaultValueCreated)\n\t\t\t\treturn true;\n\t\t\treturn bpcontext.Values.GetSpecificity() != SetterSpecificity.DefaultValue;\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Determines whether a bindable property has been set by a local value, style, binding, or other non-default specificity.\n\t\t/// Unlike IsSet, default-value creation does not count as explicit.\n\t\t/// </summary>\n\t\t/// <param name=\"targetProperty\">The bindable property to check if a value is explicitly set.</param>\n\t\t/// <returns><see langword=\"true\"/> if the target property exists and has been explicitly set. Otherwise <see langword=\"false\"/>.</returns>\n\t\t/// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"targetProperty\"/> is <see langword=\"null\"/>.</exception>\n\t\tinternal bool IsSetExplicitly(BindableProperty targetProperty)\n\t\t{\n\t\t\tvar bpcontext = GetContext(targetProperty ?? throw new ArgumentNullException(nameof(targetProperty)));\n\t\t\treturn bpcontext is not null && bpcontext.Values.GetSpecificity() != SetterSpecificity.DefaultValue;","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/BindableObject.cs#L230-L266","documentation":"Thrown by the public BindableObject.IsSet(BindableProperty) when targetProperty is null. The method uses an inline null-coalescing throw (GetContext(targetProperty ?? throw new ArgumentNullException(nameof(targetProperty)))) because it needs a real property to look up the value context.","triggerScenarios":"Calling IsSet(null) or IsSet(prop) where prop evaluates to null, so the '?? throw' expression fires.","commonSituations":"Checking whether a property is set via a resolver that returned null; guarding against a property that may not exist on the current type; passing a BindableProperty from another type by mistake.","solutions":["Pass a non-null BindableProperty (e.g. VisualElement.IsVisibleProperty).","Guard the call: if (prop is not null && obj.IsSet(prop)) { ... }.","Resolve the BindableProperty from the correct type so it is never null."],"exampleFix":"// before\nbool set = obj.IsSet(maybeNullProp);\n// after\nbool set = maybeNullProp is not null && obj.IsSet(maybeNullProp);","handlingStrategy":"validation","validationCode":"static bool SafeIsSet(BindableObject obj, BindableProperty? p)\n    => p is not null && obj.IsSet(p);","typeGuard":"static bool IsValidProperty(BindableProperty? p) => p is not null;","tryCatchPattern":null,"preventionTips":["Resolve BindableProperty from the correct type so it is never null.","Null-check before IsSet when the source may be absent.","Prefer the public IsSet API over reflective lookups in application code."],"tags":["bindable-object","null-argument","isset"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}