{"record":{"id":"7d765067fc2ac2d9","repo":"PrismLibrary/Prism","slug":"target","errorCode":null,"errorMessage":"target","messagePattern":"target","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs","lineNumber":32,"sourceCode":"    /// The behavior key.\n    /// </summary>\n    public const string BehaviorKey = \"ClearChildViews\";\n\n    /// <summary>\n    /// This attached property can be defined on a view to indicate that regions defined in it must be removed from the region manager when the parent view gets removed from a region.\n    /// </summary>\n    public static readonly BindableProperty ClearChildViewsProperty =\n        BindableProperty.CreateAttached(\"ClearChildViews\", typeof(bool), typeof(ClearChildViewsRegionBehavior), false);\n\n    /// <summary>\n    /// Gets the ClearChildViews attached property from a BindableObject.\n    /// </summary>\n    /// <param name=\"target\">The object from which to get the value.</param>\n    /// <returns>The value of the ClearChildViews attached property in the target specified.</returns>\n    public static bool GetClearChildViews(BindableObject target)\n    {\n        if (target == null)\n            throw new ArgumentNullException(nameof(target));\n\n        return (bool)target.GetValue(ClearChildViewsProperty);\n    }\n\n    /// <summary>\n    /// Sets the ClearChildViews attached property in a BindableObject.\n    /// </summary>\n    /// <param name=\"target\">The object in which to set the value.</param>\n    /// <param name=\"value\">The value of to set in the target object's ClearChildViews attached property.</param>\n    public static void SetClearChildViews(BindableObject target, bool value)\n    {\n        if (target == null)\n            throw new ArgumentNullException(nameof(target));\n\n        target.SetValue(ClearChildViewsProperty, value);\n    }\n\n    /// <summary>","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs#L14-L50","documentation":"ClearChildViewsRegionBehavior.GetClearChildViews is the getter for the ClearChildViews attached property and throws ArgumentNullException when the target BindableObject is null. This mirrors the MAUI attached-property convention that getters require a valid target.","triggerScenarios":"Calling ClearChildViewsRegionBehavior.GetClearChildViews(null), typically from code that reads the attached property off a control reference that failed to resolve or was not yet created.","commonSituations":"Reading the property in cleanup/navigation code where the page or element reference is null (element already unloaded/disposed); helper utilities querying the property on optional elements without null checks.","solutions":["Null-check the element before reading the ClearChildViews attached property","Fix the upstream reference so a valid BindableObject is passed (the element may not exist yet or was already disposed)","Use target.GetValue(ClearChildViewsProperty) guarded by a null check, or drop the read when the target is absent"],"exampleFix":"// before\nvar clear = ClearChildViewsRegionBehavior.GetClearChildViews(element); // element null\n\n// after\nvar clear = element is not null && ClearChildViewsRegionBehavior.GetClearChildViews(element);","handlingStrategy":"type-guard","validationCode":"var clear = element is null ? false : ClearChildViewsRegionBehavior.GetClearChildViews(element);","typeGuard":"bool GetClearChildViewsSafe(BindableObject target) => target is not null && ClearChildViewsRegionBehavior.GetClearChildViews(target);","tryCatchPattern":"try { var v = ClearChildViewsRegionBehavior.GetClearChildViews(target); }\ncatch (ArgumentNullException) { /* target not resolved; treat as default false */ }","preventionTips":["Null-check elements before reading attached properties","Avoid reading attached properties on disposed/unloaded elements","Treat missing targets as property default (false) in cleanup logic"],"tags":["prism","maui","regions","attached-property","null-argument"],"backgroundTag":"null-argument","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}