{"record":{"id":"8d2c3b8349b7f0cd","repo":"PrismLibrary/Prism","slug":"resources-valuemustbeoftypemoduleinfo","errorCode":null,"errorMessage":"Resources.ValueMustBeOfTypeModuleInfo","messagePattern":"Resources\\.ValueMustBeOfTypeModuleInfo","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Wpf/Prism.Wpf/Modularity/ModuleInfoGroup.cs","lineNumber":191,"sourceCode":"        }\n\n        /// <summary>\n        /// Determines whether the <see cref=\"ModuleInfoGroup\"/> contains a specific value.\n        /// </summary>\n        /// <param name=\"value\">\n        /// The <see cref=\"T:System.Object\"/> to locate in the <see cref=\"ModuleInfoGroup\"/>.\n        /// Must be of type <see cref=\"IModuleInfo\"/>\n        /// </param>\n        /// <returns>\n        /// true if the <see cref=\"T:System.Object\"/> is found in the <see cref=\"ModuleInfoGroup\"/>; otherwise, false.\n        /// </returns>\n        bool IList.Contains(object value)\n        {\n            if (value == null)\n                throw new ArgumentNullException(nameof(value));\n\n            if (!(value is IModuleInfo moduleInfo))\n                throw new ArgumentException(Resources.ValueMustBeOfTypeModuleInfo, nameof(value));\n\n            return Contains(moduleInfo);\n        }\n\n        /// <summary>\n        /// Determines the index of a specific item in the <see cref=\"ModuleInfoGroup\"/>.\n        /// </summary>\n        /// <param name=\"value\">\n        /// The <see cref=\"T:System.Object\"/> to locate in the <see cref=\"ModuleInfoGroup\"/>.\n        /// Must be of type <see cref=\"ModuleInfo\"/>\n        /// </param>\n        /// <returns>\n        /// The index of <paramref name=\"value\"/> if found in the list; otherwise, -1.\n        /// </returns>\n        public int IndexOf(object value) => _modules.IndexOf((IModuleInfo)value);\n\n        /// <summary>\n        /// Inserts an item to the <see cref=\"ModuleInfoGroup\"/> at the specified index.","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Wpf/Prism.Wpf/Modularity/ModuleInfoGroup.cs#L173-L209","documentation":"ModuleInfoGroup's explicit IList.Contains(object) implementation throws ArgumentException with Resources.ValueMustBeOfTypeModuleInfo when the supplied value is not null but does not implement IModuleInfo. Because IList is non-generic, Prism must reject wrong-typed items explicitly rather than silently returning false. A null argument raises ArgumentNullException instead.","triggerScenarios":"Calling IList.Contains on a ModuleInfoGroup (or via non-generic ICollection/IList APIs, data binding, or serializers) with an object that is not a ModuleInfo/IModuleInfo.","commonSituations":"Legacy non-generic collection code or ArrayList-style checks; WPF binding passing a view-model item instead of a ModuleInfo; LINQ/Cast misuse where a wrong element type reaches the IList API; reflection-based tests probing Contains with sentinel objects.","solutions":["Use the strongly-typed Contains(IModuleInfo) / Items.Contains method instead of the non-generic IList.Contains overload.","Ensure the value being tested is a ModuleInfo (or implements IModuleInfo) before calling.","Replace non-generic collection interactions with IEnumerable<IModuleInfo>/LINQ over Items.","If handling external/untyped input, type-check first: value is IModuleInfo before invoking Contains."],"exampleFix":"// before\nIList list = group;\nbool has = list.Contains(someViewModel);\n\n// after\nbool has = someViewModel is IModuleInfo mi && group.Contains(mi);","handlingStrategy":"type-guard","validationCode":"bool exists = value is IModuleInfo mi && group.Contains(mi);","typeGuard":"static bool GroupContains(ModuleInfoGroup g, object value) => value is IModuleInfo mi && g.Contains(mi);","tryCatchPattern":"try { ((IList)group).Contains(value); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"ModuleInfo\")) { logger.LogWarning(\"Non-module item tested against group\"); }","preventionTips":["Use the strongly-typed Contains overload whenever possible.","Avoid non-generic IList APIs on ModuleInfoGroup.","Ensure bound/serialized items implement IModuleInfo.","Handle null separately to distinguish ArgumentNullException."],"tags":["type-mismatch","collection","modularity","wpf"],"backgroundTag":"type-mismatch","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"}