{"record":{"id":"0c61dad72c09250d","repo":"PrismLibrary/Prism","slug":"value-cannot-be-null-parameter-dependson","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'dependsOn')","messagePattern":"Value cannot be null\\. \\(Parameter 'dependsOn'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Modularity/ModuleInfo.cs","lineNumber":36,"sourceCode":"    /// 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>\n    /// <param name=\"type\">The module's type.</param>\n    public ModuleInfo(string name, string type)","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Modularity/ModuleInfo.cs#L18-L54","documentation":"ModuleInfo's main constructor throws ArgumentNullException when the dependsOn array is null. Explicitly passing null as the params argument triggers this, while omitting the argument yields an empty array which is fine. The catalog needs a (possibly empty) dependency list.","triggerScenarios":"new ModuleInfo(\"Foo\", type, null) — explicitly passing null as the params argument instead of omitting it; forwarding a nullable dependency collection that is null.","commonSituations":"Programmatic module catalog construction where a dependencies list from config was null and passed straight through; overload confusion where callers assume params can be null.","solutions":["Omit the argument for no dependencies: new ModuleInfo(\"Foo\", type)","Pass an empty array: Array.Empty<string>() or new string[0]","Coalesce null dependency collections: dependsOn ?? Array.Empty<string>()"],"exampleFix":"// before\nvar info = new ModuleInfo(\"FooModule\", typeof(FooModule).AssemblyQualifiedName, dependencies); // dependencies is null\n// after\nvar info = new ModuleInfo(\"FooModule\", typeof(FooModule).AssemblyQualifiedName, dependencies ?? Array.Empty<string>());","handlingStrategy":"validation","validationCode":"var deps = configuredDependencies ?? Array.Empty<string>();\nvar info = new ModuleInfo(\"FooModule\", typeof(FooModule).AssemblyQualifiedName, deps);","typeGuard":null,"tryCatchPattern":"try\n{\n    var info = new ModuleInfo(name, type, dependencies);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"dependsOn\")\n{\n    logger.LogWarning(\"Null dependency list for {Module}; treating as none\", name);\n    var info = new ModuleInfo(name, type);\n}","preventionTips":["Omit the params argument instead of passing null when a module has no dependencies","Coalesce nullable dependency collections with ?? Array.Empty<string>()","Remember params parameters accept omission but throw on explicit null here"],"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"}