{"record":{"id":"02466cf3eaa69233","repo":"PrismLibrary/Prism","slug":"value-cannot-be-null-parameter-name","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'name')","messagePattern":"Value cannot be null\\. \\(Parameter 'name'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Modularity/ModuleInfo.cs","lineNumber":34,"sourceCode":"{\n    /// <summary>\n    /// Initializes a new empty instance of <see cref=\"ModuleInfo\"/>.\n    /// </summary>\n    public ModuleInfo()\n    {\n    }\n\n    /// <summary>\n    /// Initializes a new instance of <see cref=\"ModuleInfo\"/>.\n    /// </summary>\n    /// <param name=\"name\">The module's name.</param>\n    /// <param name=\"type\">The module <see cref=\"Type\"/>'s AssemblyQualifiedName.</param>\n    /// <param name=\"dependsOn\">The modules this instance depends on.</param>\n    /// <exception cref=\"ArgumentNullException\">An <see cref=\"ArgumentNullException\"/> is thrown if <paramref name=\"dependsOn\"/> is <see langword=\"null\"/>.</exception>\n    public ModuleInfo(string name, string type, params string[] dependsOn)\n    {\n        if (string.IsNullOrWhiteSpace(name))\n            throw new ArgumentNullException(nameof(name));\n        if (dependsOn == null)\n            throw new ArgumentNullException(nameof(dependsOn));\n\n        ModuleType = Type.GetType(type) ?? throw new ArgumentNullException(nameof(type));\n        ModuleName = name;\n        foreach (string dependency in dependsOn)\n        {\n            if (!DependsOn.Contains(dependency))\n            {\n                DependsOn.Add(dependency);\n            }\n        }\n    }\n\n    /// <summary>\n    /// Initializes a new instance of <see cref=\"ModuleInfo\"/>.\n    /// </summary>\n    /// <param name=\"name\">The module's name.</param>","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Modularity/ModuleInfo.cs#L16-L52","documentation":"The ModuleInfo(string name, string type, params string[] dependsOn) constructor throws ArgumentNullException when the module name is null or whitespace. Every module in the Prism catalog must have a non-empty ModuleName used for dependency resolution and lookup.","triggerScenarios":"new ModuleInfo(null, \"MyApp.Modules.FooModule\") or new ModuleInfo(\"\", ...) or new ModuleInfo(\"   \", ...); typically the name comes from configuration that is missing or empty.","commonSituations":"Module catalog configuration with a missing or empty name attribute; programmatic catalog building that forwards an unset variable; deserializing module definitions from a file with absent keys.","solutions":["Supply a non-empty module name: new ModuleInfo(\"FooModule\", typeof(FooModule).AssemblyQualifiedName)","Validate configuration values before constructing ModuleInfo","If loading from config, fix the missing/empty module name entry"],"exampleFix":"// before\nvar info = new ModuleInfo(config.Name, config.Type); // config.Name is \"\"\n// after\nif (string.IsNullOrWhiteSpace(config.Name)) throw new InvalidOperationException(\"Module name missing from configuration\");\nvar info = new ModuleInfo(config.Name, config.Type);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(moduleConfig.Name))\n    throw new InvalidOperationException($\"Module '{moduleConfig.Type}' has no name in configuration\");\nvar info = new ModuleInfo(moduleConfig.Name, moduleConfig.Type);","typeGuard":null,"tryCatchPattern":"try\n{\n    var info = new ModuleInfo(name, type);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"name\")\n{\n    logger.LogError(ex, \"Module name missing — check moduleCatalog configuration\");\n    throw;\n}","preventionTips":["Validate module catalog configuration at startup before constructing ModuleInfo","Give every module a stable, explicit name constant","Add config schema validation for module entries"],"tags":["null-argument","modularity","module-catalog","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"}