Files
2026-04-17 14:55:32 -04:00

7.1 KiB
Raw Permalink Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/TestSetups/TestSetupsList/TestSetupsListModule.cs
2026-04-16T04:49:23.313848+00:00 Qwen/Qwen3-Coder-Next-FP8 1 1fee89a0c4c9616a

TestSetupsList

Documentation: TestSetupsListModule


1. Purpose

The TestSetupsListModule is a Prism-based modular component responsible for registering the view and view model for the Test Setups List UI section within the application. It integrates with the Unity dependency injection container to expose the ITestSetupsListView and ITestSetupsListViewModel types as singleton registrations, enabling the main shell to instantiate and display the test setups list UI. Additionally, it provides assembly-level metadata via custom attributes (TestSetupsListModuleNameAttribute, TestSetupsListModuleImageAttribute) used by the host application to render module information (e.g., name, icon, group, region) on the main screen.


2. Public Interface

TestSetupsListModule class

  • TestSetupsListModule(IUnityContainer unityContainer)
    Constructor. Accepts and stores a reference to the Unity container for later registration of types.

  • void Initialize()
    Registers two types as singletons in the Unity container:

    • ITestSetupsListViewTestSetupsListView
    • ITestSetupsListViewModelTestSetupsListViewModel
      This method is called both directly from the constructor (via RegisterTypes) and explicitly by Prism during module initialization.
  • void OnInitialized(IContainerProvider containerProvider)
    Currently empty. No logic is executed during Prisms OnInitialized phase.

  • void RegisterTypes(IContainerRegistry containerRegistry)
    Delegates to Initialize(), which performs the actual Unity registrations. Note: Although the parameter containerRegistry is of type IContainerRegistry (Prisms abstraction), the implementation ignores it and uses the injected IUnityContainer instance instead.

TestSetupsListModuleNameAttribute class

  • TestSetupsListModuleNameAttribute() / TestSetupsListModuleNameAttribute(string s)
    Constructor. Sets AssemblyName to AssemblyNames.TestSetupsList.ToString().

  • string AssemblyName { get; }
    Returns "TestSetupsList" (value of AssemblyNames.TestSetupsList.ToString()).

  • Type GetAttributeType()
    Returns typeof(TextAttribute).

  • string GetAssemblyName()
    Returns the value of AssemblyName.

TestSetupsListModuleImageAttribute class

  • TestSetupsListModuleImageAttribute() / TestSetupsListModuleImageAttribute(string s)
    Constructor. Loads the assembly image via AssemblyInfo.GetImage("TestSetupsList").

  • BitmapImage AssemblyImage { get; }
    Returns the image loaded by AssemblyInfo.GetImage("TestSetupsList").

  • string AssemblyName { get; }
    Returns "TestSetupsList".

  • string AssemblyGroup { get; }
    Returns "Prepare" (value of eAssemblyGroups.Prepare.ToString()).

  • eAssemblyRegion AssemblyRegion { get; }
    Returns eAssemblyRegion.TestSetupsListRegion.

  • Type GetAttributeType()
    Returns typeof(ImageAttribute).

  • BitmapImage GetAssemblyImage()
    Returns AssemblyImage.

  • string GetAssemblyName()
    Returns AssemblyName.

  • string GetAssemblyGroup()
    Returns AssemblyGroup.

  • eAssemblyRegion GetAssemblyRegion()
    Returns AssemblyRegion.


3. Invariants

  • The TestSetupsListModule must be loaded after the Unity container is available and before any view resolution for ITestSetupsListView or ITestSetupsListViewModel occurs.
  • AssemblyNames.TestSetupsList, eAssemblyGroups.Prepare, and eAssemblyRegion.TestSetupsListRegion must be defined elsewhere (e.g., in DTS.Common), and their values are assumed constant and correct at runtime.
  • The AssemblyInfo.GetImage(...) call in TestSetupsListModuleImageAttribute must succeed and return a non-null BitmapImage; otherwise, the UI may fail to render the module icon.
  • All registrations in Initialize() are singleton (default Unity behavior for RegisterType<T, TImpl>() without specifying lifetime).
  • The RegisterTypes method is expected to be invoked by Prism during module initialization, and its side effects (registrations) must be idempotent (though Unity will throw if re-registering the same mapping without clearing, this is not guarded against in the source).

4. Dependencies

Dependencies of this module:

  • DTS.Common — Provides core types: AssemblyNames, eAssemblyGroups, eAssemblyRegion, AssemblyInfo, TextAttribute, ImageAttribute.
  • Prism.Modularity — Defines IModule, IContainerProvider, IContainerRegistry.
  • Prism.Ioc — Defines IContainerProvider, IContainerRegistry.
  • Unity — Defines IUnityContainer.
  • System.ComponentModel.Composition — Used for [Export] attribute.
  • System.Windows.Media.Imaging — Used for BitmapImage.

Dependencies on this module:

  • The main shell/application depends on this module to provide the ITestSetupsListView and ITestSetupsListViewModel types for UI composition.
  • Other modules or services may depend on the presence of the TestSetupsListRegion (via eAssemblyRegion.TestSetupsListRegion) to inject content into the correct region.

5. Gotchas

  • Redundant Initialize() call: RegisterTypes calls Initialize(), but Initialize() is also called in the constructor. This means registrations occur twice during module startup — once in the constructor, and again via RegisterTypes. While Unity may silently ignore duplicate registrations (depending on version/config), this is inefficient and could mask bugs if registration logic changes.
  • IContainerRegistry ignored: The RegisterTypes method receives a Prism IContainerRegistry, but uses the injected IUnityContainer instead. This tightly couples the module to Unity and breaks Prisms container abstraction. It may cause issues if the host switches to a different DI container (e.g., DryIoc, Microsoft.Extensions.DependencyInjection).
  • No error handling: If AssemblyInfo.GetImage(...) returns null (e.g., missing image resource), the AssemblyImage property will be null, potentially causing UI rendering failures with no clear diagnostic.
  • Assembly-level attributes: The [assembly: ...] attributes are applied at the assembly level, but their usage (e.g., discovery by the host) is not visible in this module. Their behavior depends on external logic (e.g., reflection scanning by the shell).
  • Unused parameter s: Both attribute constructors accept a string s parameter but ignore it — likely legacy or placeholder.
  • Missing OnInitialized logic: The OnInitialized method is empty; if future logic requires coordination with other modules, this will need implementation.

None identified from source alone. (Note: The above are inferred from code structure and patterns; they are not explicit bugs but represent design decisions or potential risks.)