{"record":{"id":"32d9e1579be25dd1","repo":"PrismLibrary/Prism","slug":"modules","errorCode":null,"errorMessage":"modules","messagePattern":"modules","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Prism.Core/Modularity/ModuleCatalogBase.cs","lineNumber":50,"sourceCode":"\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"IModuleCatalog\"/> class.\n        /// </summary>\n        public ModuleCatalogBase()\n        {\n            _items = new ModuleCatalogItemCollection();\n            _items.CollectionChanged += ItemsCollectionChanged;\n        }\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"IModuleCatalog\"/> class while providing an\n        /// initial list of <see cref=\"IModuleInfo\"/>s.\n        /// </summary>\n        /// <param name=\"modules\">The initial list of modules.</param>\n        public ModuleCatalogBase(IEnumerable<IModuleInfo> modules)\n            : this()\n        {\n            if (modules == null) throw new ArgumentNullException(nameof(modules));\n            foreach (IModuleInfo moduleInfo in modules)\n            {\n                Items.Add(moduleInfo);\n            }\n        }\n\n        /// <summary>\n        /// Gets the items in the <see cref=\"IModuleCatalog\"/>. This property is mainly used to add <see cref=\"IModuleInfoGroup\"/>s or\n        /// <see cref=\"IModuleInfo\"/>s through XAML.\n        /// </summary>\n        /// <value>The items in the catalog.</value>\n        public Collection<IModuleCatalogItem> Items => _items;\n\n        /// <summary>\n        /// Gets all the <see cref=\"IModuleInfo\"/> classes that are in the <see cref=\"IModuleCatalog\"/>, regardless\n        /// if they are within a <see cref=\"IModuleInfoGroup\"/> or not.\n        /// </summary>\n        /// <value>The modules.</value>","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Prism.Core/Modularity/ModuleCatalogBase.cs#L32-L68","documentation":"The ModuleCatalogBase(IEnumerable<IModuleInfo>) constructor throws ArgumentNullException when the modules collection is null. A catalog must be initialized with at least an empty sequence; null cannot be enumerated into Items.","triggerScenarios":"new ModuleCatalog((IEnumerable<IModuleInfo>)null) or passing a null result from a config loader / container resolution into the catalog constructor.","commonSituations":"Module lists read from XAML, app.config, or a DI container that return null when no modules are configured; calling code that forgets to initialize a module list field.","solutions":["Pass a non-null collection; use Array.Empty<IModuleInfo>() or new List<IModuleInfo>() when there are no modules.","Null-check or coalesce the source collection before constructing the catalog.","Fix the configuration/DI registration so the module list provider returns an empty collection instead of null."],"exampleFix":"// before\nvar catalog = new ModuleCatalog(GetModulesFromConfig()); // GetModulesFromConfig() may return null\n// after\nvar modules = GetModulesFromConfig() ?? Enumerable.Empty<IModuleInfo>();\nvar catalog = new ModuleCatalog(modules);","handlingStrategy":"validation","validationCode":"IEnumerable<IModuleInfo> modules = sourceModules ?? Enumerable.Empty<IModuleInfo>();\nvar catalog = new ModuleCatalog(modules);","typeGuard":"bool HasModules(IEnumerable<IModuleInfo> m) => m != null;","tryCatchPattern":"try\n{\n    var catalog = new ModuleCatalog(modules);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == nameof(modules))\n{\n    logger.LogWarning(\"Null module list; creating empty catalog\");\n    catalog = new ModuleCatalog();\n}","preventionTips":["Coalesce null module lists to empty enumerables at the source","Make config/DI module-list providers return empty collections, never null","Initialize module list fields with new List<IModuleInfo>()"],"tags":["argumentnull","modulecatalog","prism"],"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"}