{"record":{"id":"6558dd4ed57a2563","repo":"PrismLibrary/Prism","slug":"e","errorCode":null,"errorMessage":"e","messagePattern":"e","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs","lineNumber":110,"sourceCode":"    private void Region_PropertyChanged(object sender, PropertyChangedEventArgs e)\n    {\n        if (e.PropertyName == \"Name\" && !string.IsNullOrEmpty(Region.Name))\n        {\n            Region.PropertyChanged -= Region_PropertyChanged;\n            StartPopulatingContent();\n        }\n    }\n\n    /// <summary>\n    /// Handler of the event that fires when a new viewtype is registered to the registry.\n    /// </summary>\n    /// <remarks>Although this is a public method to support Weak Delegates in Silverlight, it should not be called by the user.</remarks>\n    /// <param name=\"sender\"></param>\n    /// <param name=\"e\"></param>\n    public virtual void OnViewRegistered(object sender, ViewRegisteredEventArgs e)\n    {\n        if (e == null)\n            throw new ArgumentNullException(nameof(e));\n\n        if (e.RegionName == Region.Name)\n        {\n            AddViewIntoRegion((VisualElement)e.GetView(Region.Container()));\n        }\n    }\n}\n","sourceCodeStart":92,"sourceCodeEnd":118,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs#L92-L118","documentation":"AutoPopulateRegionBehavior.OnViewRegistered handles ViewRegisteredEventArgs from the view registry and throws ArgumentNullException when the event args e is null. It then matches e.RegionName against the behavior's region and adds the registered view into the region.","triggerScenarios":"Raising the view-registered callback with null ViewRegisteredEventArgs — i.e. invoking the WeakEvent/subscription path that calls OnViewRegistered(sender, null). Normally only reachable from custom IRegionViewRegistry code or tests firing the event manually.","commonSituations":"Custom view-registry implementations invoking the handler directly; unit tests simulating view registration with null args; mis-wired weak delegate subscriptions passing null payload.","solutions":["Ensure the IRegionViewRegistry always raises ViewRegistered with a non-null ViewRegisteredEventArgs","Fix custom registry/event-raising code to construct valid event args","If calling OnViewRegistered directly (e.g. in tests), pass a properly constructed ViewRegisteredEventArgs"],"exampleFix":"// before\nbehavior.OnViewRegistered(this, null);\n\n// after\nbehavior.OnViewRegistered(this, new ViewRegisteredEventArgs { RegionName = \"MyRegion\", View = viewFactory });","handlingStrategy":"validation","validationCode":"if (args is null) throw new InvalidOperationException(\"ViewRegisteredEventArgs must be constructed before raising the event\");","typeGuard":null,"tryCatchPattern":"try { behavior.OnViewRegistered(sender, args); }\ncatch (ArgumentNullException) { /* registry raised null args; fix event-raising code */ }","preventionTips":["Always raise ViewRegistered with a constructed ViewRegisteredEventArgs","In custom registries, validate args before invoking handlers","In tests, build real event args rather than passing null"],"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"}