{"record":{"id":"6610b8c2394ae9c9","repo":"PrismLibrary/Prism","slug":"view","errorCode":null,"errorMessage":"view","messagePattern":"view","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/Regions/Region.cs","lineNumber":347,"sourceCode":"            visualElement.ClearValue(Xaml.RegionManager.RegionManagerProperty);\n        }\n    }\n\n    /// <summary>\n    /// Removes all views from the region.\n    /// </summary>\n    public void RemoveAll()\n    {\n        foreach (var view in Views)\n        {\n            Remove(view);\n        }\n    }\n\n    private ItemMetadata GetItemMetadataOrThrow(object view)\n    {\n        if (view == null)\n            throw new ArgumentNullException(nameof(view));\n\n        var itemMetadata = ItemMetadataCollection.FirstOrDefault(x => x.Item == view);\n\n        if (itemMetadata == null)\n            throw new ArgumentException(Resources.ViewNotInRegionException, nameof(view));\n\n        return itemMetadata;\n    }\n\n    internal static int DefaultSortComparison(object x, object y)\n    {\n        if (x == null)\n        {\n            if (y == null)\n            {\n                return 0;\n            }\n            else","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/Regions/Region.cs#L329-L365","documentation":"Region.GetItemMetadataOrThrow throws ArgumentNullException for the 'view' parameter when Remove/activation bookkeeping is handed a null view. It looks up the view's ItemMetadata first, so a null instance fails immediately.","triggerScenarios":"Calling region.Remove(null), or a Remove call where the view variable is null because a previous GetView/lookup returned null and was not checked.","commonSituations":"Chained code like region.Remove(region.GetView(name)) where GetView returned null; null flowing from a failed navigation resolution.","solutions":["Null-check the view before calling region.Remove/view operations.","Check the result of region.GetView(name) for null before using it.","Determine why the view variable is null — usually a failed earlier lookup or an unset field."],"exampleFix":"// before\nregion.Remove(region.GetView(\"details\"));\n\n// after\nvar view = region.GetView(\"details\");\nif (view != null) region.Remove(view);","handlingStrategy":"validation","validationCode":"if (view == null) return;","typeGuard":"static bool IsRemovable(IRegion region, object view) => view != null && region.Views.Contains(view);","tryCatchPattern":"try { region.Remove(view); } catch (ArgumentNullException ex) { logger.LogWarning(ex, \"Remove called with null view\"); }","preventionTips":["Null-check results of GetView before passing them on","Avoid chaining region.Remove(region.GetView(name)) in one expression","Ensure fields holding views are initialized before cleanup runs"],"tags":["prism","maui","regions","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"}