Files
DP44/enriched-qwen3-coder-next/Common/DTS.Common.CPU.md
2026-04-17 14:55:32 -04:00

5.5 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.Common.CPU/CPUModule.cs
2026-04-16T14:12:42.546708+00:00 zai-org/GLM-5-FP8 1 5a3256f83f5993a9

Documentation: DTS.Common.CPU Module

1. Purpose

This module serves as a Prism-based plugin module for CPU-related functionality within the DTS application framework. It registers the CPUEngine implementation with the Unity dependency injection container and provides assembly metadata (name and image) used by the main application shell to display available components. The module follows the Prism modularity pattern, allowing it to be dynamically loaded and initialized at runtime.


2. Public Interface

CPUModule Class

Signature:

[Export(typeof(IModule))]
[Module(ModuleName = "CPU")]
public class CPUModule : IModule

Constructor:

public CPUModule(IUnityContainer unityContainer)

Accepts an IUnityContainer instance via constructor injection and stores it in a private readonly field _unityContainer.

Methods:

public void Initialize()

Registers ICPUEngine mapped to CPUEngine with the Unity container. Contains a commented-out registration for IPropertyViewModel mapped to PropertyViewModel.


CPUNameAttribute Class

Signature:

[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class CPUNameAttribute : TextAttribute

Constructors:

public CPUNameAttribute()
public CPUNameAttribute(string s)

Both constructors initialize _assemblyName to the hardcoded string "CPUAsssembly".

Properties:

public override string AssemblyName { get; }

Returns _assemblyName (value: "CPUAsssembly").

Methods:

public override Type GetAttributeType()
public override string GetAssemblyName()

GetAttributeType() returns typeof(TextAttribute). GetAssemblyName() returns the AssemblyName property value.


CUPImageAttribute Class

Signature:

[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class CUPImageAttribute : ImageAttribute

Constructors:

public CUPImageAttribute()
public CUPImageAttribute(string s)

Both constructors initialize _img by calling AssemblyInfo.GetImage(AssemblyNames.CPU.ToString()).

Properties:

public override BitmapImage AssemblyImage { get; }
public override string AssemblyName { get; }
public override string AssemblyGroup { get; }
public override eAssemblyRegion AssemblyRegion { get; }
  • AssemblyImage: Lazily initializes and returns a BitmapImage from AssemblyInfo.GetImage().
  • AssemblyName: Returns AssemblyNames.CPU.ToString().
  • AssemblyGroup: Returns eAssemblyGroups.Viewer.ToString().
  • AssemblyRegion: Returns eAssemblyRegion.NotAssigned.

Methods:

public override Type GetAttributeType()
public override BitmapImage GetAssemblyImage()
public override string GetAssemblyName()
public override eAssemblyRegion GetAssemblyRegion()
public override string GetAssemblyGroup()

All return their corresponding property values. GetAttributeType() returns typeof(ImageAttribute).


3. Invariants

  • The _unityContainer field is initialized only once via constructor injection and is never null after construction (assuming the DI container provides a valid instance).
  • CPUNameAttribute and CUPImageAttribute are applied at the assembly level with AllowMultiple = false, meaning only one instance of each should exist per assembly.
  • The AssemblyName property in CPUNameAttribute always returns "CPUAsssembly" regardless of constructor arguments.
  • The AssemblyGroup in CUPImageAttribute is always eAssemblyGroups.Viewer.
  • The AssemblyRegion in CUPImageAttribute is always eAssemblyRegion.NotAssigned.

4. Dependencies

This module depends on:

  • System.Windows.Media.Imaging — For BitmapImage type.
  • System.ComponentModel.Composition — For MEF [Export] attribute.
  • Microsoft.Practices.Prism.Modularity — For IModule interface and [Module] attribute.
  • Microsoft.Practices.Unity — For IUnityContainer interface.
  • DTS.Common.Interface — For TextAttribute, ImageAttribute, ICPUEngine, AssemblyInfo, AssemblyNames, eAssemblyGroups, and eAssemblyRegion (inferred from usage).

What depends on this module:

  • Cannot be determined from this source file alone. Likely consumed by a main application shell that scans for Prism modules and displays assembly metadata.

5. Gotchas

  1. Typo in class name: CUPImageAttribute appears to be a typo for CPUImageAttribute. The assembly attribute at line 9 is [assembly: CUPImage()] which matches this typo.

  2. Typo in assembly name string: CPUNameAttribute hardcodes _assemblyName = "CPUAsssembly" (note the double 's'). This may cause display issues or lookup failures if other code expects "CPUAssembly".

  3. Ignored constructor parameter: Both attribute classes accept a string s parameter in their constructors but completely ignore it, always using hardcoded values instead.

  4. Commented-out registration: The Initialize() method contains a commented-out registration for IPropertyViewModel. It is unclear whether this is intentional tech debt or deprecated functionality.

  5. Side effect in property getter: The AssemblyImage property getter has a side effect—it assigns to _img before returning. This is unusual for a property getter and could cause unexpected behavior if the property is accessed multiple times.