{"record":{"id":"8ad5bb6a3329021b","repo":"PrismLibrary/Prism","slug":"regionname","errorCode":null,"errorMessage":"regionName","messagePattern":"regionName","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterBase.cs","lineNumber":40,"sourceCode":"    }\n\n    /// <summary>\n    /// Gets or sets the factory used to create the region behaviors to attach to the created regions.\n    /// </summary>\n    protected IRegionBehaviorFactory RegionBehaviorFactory { get; set; }\n\n    /// <summary>\n    /// Adapts an object and binds it to a new <see cref=\"IRegion\"/>.\n    /// </summary>\n    /// <param name=\"regionTarget\">The object to adapt.</param>\n    /// <param name=\"regionName\">The name of the region to be created.</param>\n    /// <returns>The new instance of <see cref=\"IRegion\"/> that the <paramref name=\"regionTarget\"/> is bound to.</returns>\n    public IRegion Initialize(T regionTarget, string regionName)\n    {\n        var page = regionTarget.GetParentPage();\n        var container = regionTarget.GetContainerProvider();\n        IRegion region = CreateRegion(container);\n        region.Name = regionName ?? throw new ArgumentNullException(nameof(regionName));\n        if (region is ITargetAwareRegion taRegion)\n            taRegion.TargetElement = regionTarget;\n\n        var children = page.GetChildRegions(true);\n        children.Add(region);\n\n        SetObservableRegionOnHostingControl(region, regionTarget);\n\n        Adapt(region, regionTarget);\n        AttachBehaviors(region, regionTarget);\n        AttachDefaultBehaviors(region, regionTarget);\n        return region;\n    }\n\n    /// <summary>\n    /// Adapts an object and binds it to a new <see cref=\"IRegion\"/>.\n    /// </summary>\n    /// <param name=\"regionTarget\">The object to adapt.</param>","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterBase.cs#L22-L58","documentation":"RegionAdapterBase<T>.Initialize assigns region.Name = regionName, throwing ArgumentNullException when the regionName argument is null. Every region adapter funnels through this method, so a null region name during region initialization is rejected here.","triggerScenarios":"Calling IRegionAdapter.Initialize(regionTarget, null), typically reached when a control's RegionManager.RegionName attached property is set to null (or bound to a null value) and the region registration pipeline calls Initialize with that value.","commonSituations":"Binding RegionManager.RegionName to a ViewModel property that is null at bind time; programmatically calling region registration helpers without a name; renaming a region and leaving the bound property unset.","solutions":["Ensure the RegionManager.RegionName value (or the regionName argument) is a non-null, non-empty string before the view is attached","Guard any bound property feeding RegionName with a fallback value in the ViewModel","If registering regions programmatically, pass a literal or validated region name to Initialize"],"exampleFix":"// before\nstackLayout.SetValue(RegionManager.RegionNameProperty, viewModel.RegionName); // null\n\n// after\nif (!string.IsNullOrEmpty(viewModel.RegionName))\n    stackLayout.SetValue(RegionManager.RegionNameProperty, viewModel.RegionName);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(regionName)) throw new ArgumentException(\"Region name must be non-empty\", nameof(regionName));","typeGuard":null,"tryCatchPattern":"try { adapter.Initialize(target, regionName); }\ncatch (ArgumentNullException) { /* log: region name was null; fix the bound RegionName value */ }","preventionTips":["Never bind RegionManager.RegionName to a property that can be null; provide a default","Validate region names at ViewModel construction time","Use nameof() or constants for region names to avoid typos/nulls"],"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"}