5.1 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T02:14:07.054648+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 6c5b3cbd6c5102fe |
ModuleCatalog
Documentation: AggregateModuleCatalog
1. Purpose
AggregateModuleCatalog is a composite implementation of IModuleCatalog that aggregates multiple underlying module catalogs into a unified interface for module discovery and dependency resolution within the Prism-based modularity framework. It enables the system to support heterogeneous module sources (e.g., ModuleCatalog, DirectoryModuleCatalog, custom catalogs) by delegating operations to the appropriate catalog while presenting a single, flat view of all modules. It is initialized with a default ModuleCatalog instance, ensuring at least one catalog is always present for module registration.
2. Public Interface
-
AggregateModuleCatalog()
Constructor. Initializes a new instance with a single internalModuleCataloginstance added to_catalogs. No parameters. -
void AddCatalog(IModuleCatalog catalog)
Adds a newIModuleCataloginstance to the internal_catalogslist. ThrowsArgumentNullExceptionifcatalogisnull. No validation is performed on catalog type or compatibility (commented-out logic suggests past intent for such checks, but it is inactive). -
IEnumerable<ModuleInfo> Modules { get; }
Returns a flattened enumeration of allModuleInfoinstances across all internal catalogs, viaSelectMany. -
IEnumerable<ModuleInfo> GetDependentModules(ModuleInfo moduleInfo)
Returns the dependencies ofmoduleInfo. ThrowsInvalidOperationExceptionifmoduleInfois not contained in exactly one internal catalog (due to use of.Single()). Delegates to the containing catalog’sGetDependentModules. -
IEnumerable<ModuleInfo> CompleteListWithDependencies(IEnumerable<ModuleInfo> modules)
Returnsmodulesplus all transitive dependencies. Groupsmodulesby the single catalog that contains each module (throwsInvalidOperationExceptionif a module is missing or duplicated across catalogs), then delegatesCompleteListWithDependenciesper catalog and flattens results. -
void Initialize()
CallsInitialize()on each internal catalog in sequence. -
void AddModule(ModuleInfo moduleInfo)
AddsmoduleInfoexclusively to the first catalog in_catalogs(i.e., the defaultModuleCatalogcreated in the constructor). Does not attempt to distribute or search for an appropriate catalog.
3. Invariants
_catalogsalways contains at least one catalog (initialized to a newModuleCatalogin the constructor).AddModulealways targets_catalogs[0]; other catalogs are not modified by this method.GetDependentModulesandCompleteListWithDependenciesassume eachModuleInfobelongs to exactly one catalog. If aModuleInfoappears in multiple catalogs or none, these methods throwInvalidOperationException(from.Single()).Catalogsis read-only (viaAsReadOnly()), but_catalogsitself is mutable viaAddCatalog.
4. Dependencies
-
Depends on:
Microsoft.Practices.Prism.Modularity(specificallyIModuleCatalog,ModuleInfo).- Standard .NET libraries:
System,System.Collections.Generic,System.Linq.
-
Depended on by:
- Not evident from this file alone. Likely consumed by Prism’s module initialization infrastructure (e.g.,
ModuleManager,ModuleInitializer) or custom bootstrappers in the DTS codebase.
- Not evident from this file alone. Likely consumed by Prism’s module initialization infrastructure (e.g.,
5. Gotchas
- Critical ambiguity in
AddModulebehavior: It silently routes all module additions to the first catalog, ignoring others. This may lead to modules being registered in an unintended catalog if the caller assumes uniform distribution or catalog-specific registration. - Fragile catalog lookup: Both
GetDependentModulesandCompleteListWithDependenciesuse.Single(x => x.Modules.Contains(moduleInfo)), which assumes uniqueness ofModuleInfoacross catalogs. If the sameModuleInfoinstance (by reference or identity) appears in multiple catalogs—or is missing—these methods will throw at runtime. - No validation in
AddCatalog: Despite commented-out logic, no checks prevent adding duplicate catalog types (e.g., twoDirectoryModuleCatalogs) or incompatible catalogs. This may cause unexpected behavior (e.g., duplicate modules, conflicting paths). - No thread-safety: The internal
_catalogslist is modified byAddCatalogandAddModulewithout synchronization. Concurrent access may cause race conditions. - No documentation on catalog ordering semantics: The order of catalogs in
_catalogsmay affect behavior (e.g.,AddModuletargets index 0;Modulesenumeration order is catalog-order-dependent), but no guarantees or documentation are provided. - Commented-out code: The commented-out logic in
AddCatalogsuggests unresolved design questions about catalog compatibility (e.g., path handling forDirectoryModuleCatalog), indicating potential technical debt or incomplete feature implementation.