9.2 KiB
9.2 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T04:59:22.874172+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 283afdf9f6a03436 |
Documentation: Test Metadata Wrappers (Version 57)
1. Purpose
This module provides managed wrapper classes for low-level ISO.*Details types (CustomerDetails, LabratoryDetails, TestEngineerDetails) used in database export operations for Version 57 of the database schema. Its primary role is to encapsulate and standardize access to these domain entities—offering lazy-loaded, sorted, and deduplicated collections via singleton list managers (CustomerDetailsList, LabratoryDetailsList, TestEngineerDetailsList). It ensures consistent handling of a special "(none)" placeholder entry and provides thread-safe access to metadata used in test reporting and export workflows.
2. Public Interface
CustomerDetails
CustomerDetails()
Default constructor. Initializes internal_customerDetailswith a newISO.CustomerDetails, setting itsNameto"(none)".CustomerDetails(ISO.CustomerDetails customerDetails)
Copy constructor. Creates a newISO.CustomerDetailsinstance from the providedcustomerDetails.string Name { get; set; }
Gets or sets theNameproperty of the underlyingISO.CustomerDetails.ISO.CustomerDetails GetISOCustomer()
Returns the internalISO.CustomerDetailsinstance.override string ToString()
Returns theNameproperty.
CustomerDetailsList
static CustomerDetailsList CustomerList { get; }
Singleton accessor.CustomerDetails[] Customers { get; }
Returns a sorted (byName, ordinal) array of allCustomerDetails, including the "(none)" entry. Thread-safe vialockand lazy initialization.CustomerDetails[] GetAllCustomers()
Returns a fresh array containing a new "(none)"CustomerDetailsfollowed by allCustomerDetailscreated fromISO.CustomerDetails.GetAllCustomerDetails().CustomerDetails GetCustomerDetail(string name)
Returns the firstCustomerDetailsinCustomers(parallel query) matchingname, ornullif none found.
LabratoryDetails
LabratoryDetails()
Default constructor. Initializes_labwith a newISO.LabratoryDetails, settingNameto"(none)".LabratoryDetails(ISO.LabratoryDetails lab)
Copy constructor. Creates a newISO.LabratoryDetailsinstance fromlab.string Name { get; set; }
Gets or sets theNameproperty of_lab.ISO.LabratoryDetails GetIsoLab()
Returns the internal_labinstance.override string ToString()
Returns theNameproperty.
LabratoryDetailsList
protected LabratoryDetailsList()
Protected constructor (enforces singleton via private instantiation).static LabratoryDetailsList LabratoryList { get; }
Singleton accessor.LabratoryDetails[] Labs { get; }
Returns a sorted (byName, ordinal) array of allLabratoryDetails, including "(none)". Thread-safe vialockand lazy initialization.LabratoryDetails GetLab(string name)
Returns theLabratoryDetailsfornamefrom the internal_labsdictionary (if populated), ornull. Includes exception handling (logs viaAPILoggeron failure).private LabratoryDetails[] GetAllLabs()
Returns a fresh array containing a new "(none)"LabratoryDetailsfollowed by allLabratoryDetailscreated fromISO.LabratoryDetails.GetAllLabratoryDetails(). Includes exception handling.
TestEngineerDetails
TestEngineerDetails()
Default constructor. Initializes_testEngineerDetailswith a newISO.TestEngineerDetails, settingNameto"(none)".TestEngineerDetails(ISO.TestEngineerDetails testEngineerDetails)
Copy constructor. Creates a newISO.TestEngineerDetailsinstance fromtestEngineerDetails.string Name { get; set; }
Gets or sets theNameproperty of_testEngineerDetails.ISO.TestEngineerDetails GetISOTestEngineer()
Returns the internal_testEngineerDetailsinstance.override string ToString()
Returns theNameproperty.
TestEngineerDetailsList
static TestEngineerDetailsList TestEngineerList { get; }
Singleton accessor.TestEngineerDetails[] TestEngineers { get; }
Returns a sorted (byName, usingCompareTo) array of allTestEngineerDetails, including "(none)". Thread-safe vialockand lazy initialization.TestEngineerDetails[] GetAllTestEngineers()
Returns a fresh array containing a new "(none)"TestEngineerDetailsfollowed by allTestEngineerDetailscreated fromISO.TestEngineerDetails.GetAllTestEngineerDetails().TestEngineerDetails GetTestEngineerDetail(string name)
Returns the firstTestEngineerDetailsinTestEngineers(parallel LINQ query) matchingname, ornull.
3. Invariants
- "(none)" Placeholder: Each list (
CustomerDetails,LabratoryDetails,TestEngineerDetails) always includes a special entry withName == "(none)"as the first element returned byGetAll*()methods. - Deduplication: The internal
_customers,_labs, and_testEngineersdictionaries useNameas the key, ensuring only one entry per unique name (last one wins in case of duplicates inGetAll*()). - Sorted Output: The
Customers,Labs, andTestEngineersproperties return arrays sorted byNameusing ordinal string comparison (String.Compare(..., StringComparison.Ordinal)orCompareTo). - Thread Safety: All list properties (
Customers,Labs,TestEngineers) and their underlying population methods (PopulateCustomers,PopulateList,PopulateEngineers) are guarded by dedicated staticlockobjects. However,GetCustomerDetailandGetTestEngineerDetailuseAsParallel()on the already-computedCustomers/TestEngineersarray, which is safe but not optimized. - Null Handling:
Compare*methods explicitly handlenullinputs (returning-1,0, or1as appropriate).Get*Detailmethods returnnullif no match is found.
4. Dependencies
- Internal Dependencies:
ISO.CustomerDetails,ISO.LabratoryDetails,ISO.TestEngineerDetails(from theISOnamespace) — core data types being wrapped.ISO.CustomerDetails.GetAllCustomerDetails(),ISO.LabratoryDetails.GetAllLabratoryDetails(),ISO.TestEngineerDetails.GetAllTestEngineerDetails()— static methods to fetch raw data.
- External Dependencies:
DTS.Utilities.Logging.APILogger(used inLabratoryDetailsListonly) — for logging exceptions during lab retrieval.- Standard .NET:
System,System.Collections.Generic,System.Linq.
- Depended Upon: This module is part of
DatabaseExportnamespace and is likely consumed by higher-level export/reporting logic in theDataPROsystem (not visible in source).
5. Gotchas
- Inconsistent Naming: Class is named
LabratoryDetails(misspelled) instead ofLaboratoryDetails. This typo is propagated in both class and list names. - Exception Swallowing:
LabratoryDetailsListsilently swallows exceptions inGetLabandGetAllLabs(logs only viaAPILogger), which may hide failures during lab data loading. - Race Condition in
Populate*: WhilePopulate*methods are called under lock, they are not idempotent-safe in all cases:CustomerDetailsList.PopulateCustomers()checksif (null != _customers) return;— safe.TestEngineerDetailsList.PopulateEngineers()does not check_testEngineers != nullbefore reassigning — safe only because it’s called under lock and only once.LabratoryDetailsList.PopulateList()has the same safe guard (if (null != _labs) return;).
→ All are safe in practice due to locking, but the pattern is fragile.
- Redundant Copying: Both constructors (
CustomerDetails(ISO.CustomerDetails), etc.) create a new instance of the underlyingISO.*Details(via copy constructor), not a reference wrapper. This is intentional but may be surprising if mutation of the returnedISO.*Detailsis expected to affect the wrapper’s internal state. - Inconsistent
Get*DetailImplementations:CustomerDetailsList.GetCustomerDetailandTestEngineerDetailsList.GetTestEngineerDetailuseAsParallel()on the already-computed array — unnecessary overhead for small lists.LabratoryDetailsList.GetLabuses direct dictionary lookup (_labs.ContainsKey) — more efficient, but only works afterLabsproperty has been accessed (since_labsis populated inLabsgetter, not eagerly).
- No Validation: No validation on
Namevalues (e.g., empty strings, duplicates in raw data) — relies on underlyingISO.*types or data source to prevent invalid names. - Hardcoded Placeholder: The
"(none)"string is hardcoded in constructors. No constant or resource reference (despite commented-outStrings.StringResources.TestTemplate_EmptyListNameinTestEngineerDetails).