4.9 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T12:04:29.540782+00:00 | zai-org/GLM-5-FP8 | 1 | 8848a0560473ca7f |
Documentation: DTS.Common.XMLUtils
1. Purpose
This module provides XML parsing and metadata extraction utilities for DTS application files. It contains two static classes: DTSXMLFile for extracting item count information from XML files, and TestMetadataXml for aggregating and parsing multiple DTS test metadata XML files into a unified XDocument structure. The module serves as a bridge between raw XML file storage and the application's test management system.
2. Public Interface
Class: DTSXMLFile (static)
public static double GetItemsToCompleteCount(string fileName)
- Returns: The value of the
TotalItemsattribute from an XML node as adouble. - Behavior: Retrieves an import XML node via
FileUtils.GetImportXmlNode(), then extracts and converts theTotalItemsattribute usingCultureInfo.InvariantCulture. TheimportVersionparameter is passed as anoutparameter to the internal call but is not returned to the caller.
Class: TestMetadataXml (static)
public static XDocument GetTestMetadataXml(string path, string file = "", string pattern = "")
- Returns: An
XDocumentwith a root element named"Tests"containing aggregated test metadata. - Parameters:
path- Directory path to search for files.file- Optional specific file path. If provided, only this file is processed.pattern- File pattern for search. Defaults to".dts"if null or empty.
- Behavior:
- Clears and populates the static
FileUtils.FileListproperty. - If
fileis provided, adds it directly to the file list. - Otherwise, calls
FileUtils.FindFiles(path, pattern)to discover files. - Delegates to
SetTestMetadataType()for XML processing.
- Clears and populates the static
3. Invariants
- FileUtils.FileList state: The static property
FileUtils.FileListis cleared (new List<string>()) at the start of everyGetTestMetadataXml()call. Concurrent calls could result in race conditions. - Return value for
GetItemsToCompleteCount: Always returns adouble. The initialimportVersionis set to-1before callingFileUtils.GetImportXmlNode(). - XML structure assumption:
SetTestMetadataType()expects XML fragments to contain either a"Test"root element or a"TestSetup"root element. Other structures are silently ignored (the element is not added). - Error handling:
SetTestMetadataType()catches exceptions at both the file level (logs and continues) and the overall level (returns an emptyXDocument).
4. Dependencies
This module depends on:
DTS.Common.Utils(FileUtilsclass)FileUtils.GetImportXmlNode()- used inDTSXMLFileFileUtils.FileList- static list property used inTestMetadataXmlFileUtils.FindFiles()- file discovery method used inTestMetadataXml
DTS.Common.Utilities.Logging(APILoggerclass)APILogger.Log()- used for error logging inTestMetadataXml
System.Xml.Linq-XDocument,XElementfor XML manipulationSystem.IO-StreamReader,StringReader,Filefor file I/O
What depends on this module:
- Unknown from source alone - No consumers are shown in the provided files.
5. Gotchas
-
Multiple XML documents in a single file:
SetTestMetadataType()splits file contents by the string"<?xml version=", meaning a single file can contain multiple concatenated XML documents. This is a specific format requirement that is not validated—malformed files will cause silent failures. -
Static state mutation:
FileUtils.FileListis a static property that is cleared and repopulated on every call toGetTestMetadataXml(). This is not thread-safe and could cause issues in concurrent scenarios. -
Unused variable warning suppression: The file includes
// ReSharper disable UnusedVariable, suggesting there may be dead code or the developer wanted to suppress warnings about variables likexmlCounterandfullstringthat could potentially be unused in certain code paths. -
DataType attribute logic: The
DataTypeattribute is set to"ALL"if the file path contains the substring"ALL"(case-sensitive), otherwise"ROI". This simple string check could produce unexpected results if"ALL"appears elsewhere in the path. -
Empty XDocument on total failure: If an exception occurs at the outer
try-catchinSetTestMetadataType(), an emptyXDocumentis returned (no root element), which may cause null reference exceptions in consumers expecting a"Tests"root. -
importVersion not exposed: In
GetItemsToCompleteCount(), theimportVersionvalue is retrieved viaoutparameter but never returned or used by the caller. Its purpose is unclear from the source.