17 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||
|---|---|---|---|---|---|---|---|---|
|
2026-04-16T03:35:54.397147+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | d172f5c36f1bfbab |
Documentation: DTS.Serialization Namespace – Serialization Types
1. Purpose
This module provides core serialization infrastructure for test metadata in the DTS system, centered around the Test class and its associated types (DasTimestamp, IntervalSec, and the IConvertable interface). It enables structured XML serialization/deserialization of test metadata (e.g., test ID, description, modules, channels, DAS timestamps), supports equality comparison, and includes utilities for channel ordering and fault flag management. The module exists to standardize how test metadata is persisted, retrieved, and compared across the DTS ecosystem, particularly for interoperability with SLICEWare and internal tools.
2. Public Interface
IConvertable Interface
Defined in IConvertable.cs
-
Test ToDtsSerializationTest()
Converts the implementing object into aDTS.Serialization.Testinstance. -
void FromDtsSerializationTest(Test test, ReportErrors reportErrors)
Initializes the implementing object using data from aTestinstance. Errors encountered during conversion are reported via thereportErrorsdelegate.
Note
:
ReportErrorsis a delegate:public delegate void ReportErrors(List<string> errors);
Test Class
Defined in Test.cs
-
Constructors
Test()
Default constructor. InitializesInceptionDatetoDateTime.Now, callsTryGetChannelOrder(), and leavesIdandDescriptionempty.Test(string dtsfile)
Placeholder constructor (empty implementation).Test(string id, string description)
Initializes withid,description, andEventNumber = 0.Test(string id, string description, int eventNumber)
Initializes withid,description, andeventNumber.
-
Properties
string Software→"DataPRO"by default (read/write, XML-serialized as"Software").string SoftwareVersion→""by default (read/write, XML-serialized as"SoftwareVersion").DateTime InceptionDate→DateTime.Nowby default (read/write).string Id→""by default (read/write, XML-serialized as"Id").string Description→""by default (read/write, XML-serialized as"Description").int EventNumber→0by default (read/write, XML-serialized as"EventNumber").Guid Guid→Guid.Emptyby default (read/write, XML-serialized as"Guid").ushort FaultFlags→0by default (read/write, XML-serialized as"FaultFlags").uint ExtendedFaultFlags1–4→0by default (read/write, XML-serialized as"ExtendedFaultFlags1"–"ExtendedFaultFlags4").bool InlineSerializedData→falseby default (read/write, XML-serialized as"InlineSerializedData"; setting it propagates to allModules).List<Module> Modules→ empty list by default (read/write, XML-serialized as"Modules").List<DasTimestamp> DasTimestamps→ empty list by default (read/write, XML-serialized as"DasTimestamps").List<Module.Channel> Channels→ computed list of all channels (including calculated channels) fromModules, sorted byAbsoluteDisplayOrder, thenParentModule.Number, thenChannel.Number, and finally byChannelOrder.txtif present.
-
Methods
void ClearExtendedFaultFlags()
ResetsExtendedFaultFlags1–4to0.void TryGetChannelOrder()
Attempts to load channel ordering from"ChannelOrder.txt"(if present) into an internal dictionary_channelOrder. Logs exceptions viaAPILogger.void SaveTest(string directory, string testId, int defaultEncoding, bool includeGroupNameInISOExport)
Saves test metadata to a.dtsfile. Backs up existing.dtsfile (if no.bakexists), writes SLICEWare-compatible data viaSliceRaw.File.Exporter.Write(...), then appends XML-serialized<Test>metadata (usingWriteXml) in UTF-16 encoding. Deletes backup on successful save.void WriteXml(XmlWriter writer)
Serializes theTestinstance to XML using attributes tagged with[XmlSerializationTag]. Writes attributes for top-level properties, then<Modules>and<DasTimestamps>elements with nested content.void ReadXml(XmlReader reader)
Deserializes XML into theTestinstance. Reads attributes for top-level properties, then deserializes<Module>and<DasTimestamp>children using their respectiveReadXmlmethods. UsesReadSubtree()to isolate child element parsing.XmlSchema GetSchema()
Returnsnull(per comment, this method is never invoked during serialization).override bool Equals(object obj)
ComparesId,Description, andModules(via private helperModulesEquals) for equality.override int GetHashCode()
Returnsbase.GetHashCode()(no custom hashing logic).
Note
:
ModulesEqualscompares twoList<Module>by count and element-wiseEquals.
DasTimestamp Class
Defined in DasTimestamp.cs
-
Constructor
DasTimestamp(Test parentTest)
Initializes with a reference to the parentTestinstance.
-
Properties
Test ParentTest→nullby default (read-only, set only via constructor).string BaseSerialNumber→""by default (read/write, XML-serialized as"BaseSerialNumber").UInt64 NumberOfSamples→0by default (read/write, XML-serialized as"NumberOfSamples").UInt32 NumberOfBitsPerSample→0by default (read/write, XML-serialized as"NumberOfBitsPerSample").string FileName→""by default (read/write, XML-serialized as"FileName").
-
Methods
void WriteXml(XmlWriter writer)
SerializesBaseSerialNumber,NumberOfSamples, andNumberOfBitsPerSampleas XML attributes. WritesBaseSerialNumberas"NA"if conversion fails. Does not serializeFileNameorNumberOfBitsPerSamplein XML output (only readsNumberOfBitsPerSample; defaults to8 * sizeof(ulong)if missing).void ReadXml(XmlReader reader)
ReadsBaseSerialNumber,NumberOfSamples, andNumberOfBitsPerSamplefrom attributes. SetsNumberOfBitsPerSampleto8 * sizeof(ulong)(i.e.,64) if missing or unparseable.XmlSchema GetSchema()
Returnsnull.override bool Equals(object obj)
ComparesFileName,NumberOfSamples,NumberOfBitsPerSample, andBaseSerialNumber.override int GetHashCode()
Returnsbase.GetHashCode().
IntervalSec Class
Defined in IntervalSec.cs
-
Constructors
IntervalSec()
Default constructor. LeavesBeginandEnduninitialized (default0.0).IntervalSec(double begin, double end)
InitializesBeginandEndto specified values. Wraps exceptions in a newException.
-
Properties
bool DoRoundOffValues→falseby default (read/write).int NumberRoundingDecimalPlaces→6by default (read/write, viaProperty<int>wrapper).double Begin→0.0by default (read/write).
Rounds toNumberRoundingDecimalPlacesifDoRoundOffValuesistrue.double End→0.0by default (read/write).
Rounds toNumberRoundingDecimalPlacesifDoRoundOffValuesistrue.
-
Methods
override bool Equals(object obj)
ComparesBeginandEndusingdouble.Equals().override int GetHashCode()
Returnsbase.GetHashCode().
Note
:
IntervalSecinherits fromExceptional(not shown in source), which likely provides exception-handling infrastructure.
3. Invariants
-
Test.IdandTest.Description
May be empty strings after default construction; no validation enforced. -
Test.Guid
Defaults toGuid.Empty; no uniqueness guarantee is enforced by the class itself. -
Test.InceptionDate
Always initialized toDateTime.Nowin the default constructor. -
Test.Channelsordering
Channels are sorted by:AbsoluteDisplayOrderParentModule.NumberChannel.Number
...and then reordered byChannelOrder.txtif present (viaChannelOrderComparor).
Critical: IfChannelOrder.txtis missing or unreadable, only the first three criteria apply.
-
DasTimestamp.NumberOfBitsPerSample
Defaults to64(i.e.,8 * sizeof(ulong)) if missing in XML during deserialization. -
Test.SaveTestbehavior
Backs up.dtsfile only if no.bakexists at the time of save. Backup is deleted on successful save. -
XML attribute extraction
UsesAttributeExtractor<XmlSerializationTagAttribute>to map property names to XML attribute names. Property names must match exactly (e.g.,"BaseSerialNumber"→ attribute"BaseSerialNumber").
4. Dependencies
Internal Dependencies (from source)
DTS.Common.UtilitiesDotNetProgrammingConstructs.Property<T>: Used for property wrappers with metadata (e.g.,Property<double>,Property<string>).Logging.APILogger: Used for logging exceptions (e.g., inTryGetChannelOrder,SaveTest).Xml.AttributeExtractor<T>: Used to extract[XmlSerializationTag]attributes for XML serialization.
DTS.Common.Utilities.XmlSliceRaw.FileandSliceRaw.File.Exporter: Used inTest.SaveTestfor SLICEWare-compatible export.
System.Xml.SerializationIXmlSerializableinterface (implemented byTestandDasTimestamp).
System.Collections.GenericDictionary<string, int>for channel ordering (_channelOrder).List<T>forModules,DasTimestamps, andChannels.
External Dependencies (inferred)
ChannelOrder.txt: Required for channel ordering (loaded at runtime viaTryGetChannelOrder()).APILogger: External logging utility (not defined in source; assumed to be a static logger).SliceRaw.File.Exporter.Write(...): External serialization utility for SLICEWare compatibility.
Inferred Consumers
- Any code that needs to serialize/deserialize test metadata (e.g.,
Test.SaveTest, XML readers/writers). - Code that needs channel ordering (e.g.,
Test.Channels). - Code that converts custom objects to/from
TestviaIConvertable.
5. Gotchas
-
IntervalSecdefault constructor leavesBegin/Enduninitialized
Though initialized to0.0, the comment warns this is "uninitialized". Callers must explicitly set values. -
DasTimestamp.WriteXmlomitsFileNameandNumberOfBitsPerSample
OnlyBaseSerialNumberandNumberOfSamplesare written to XML.NumberOfBitsPerSampleis read but not written. This asymmetry may cause data loss. -
Test.SaveTestoverwrites.dtsin-place
Appends XML metadata to the existing.dtsfile (after SLICEWare data). If the original file is corrupted or truncated, this may cause issues. -
Test.SaveTestuses UTF-16 for XML metadata
HardcodedEncoding.Unicode(UTF-16) for appended XML. May conflict with SLICEWare’s expectations if it assumes ASCII/UTF-8. -
Test.GuidandTest.FaultFlagsuse fallback defaults on deserialization
Guiddefaults toGuid.Emptyon parse failure;FaultFlagsdefaults to0. No error is raised. -
ExtendedFaultFlags1–4are optional in XML
GetUintSafereturns0if attributes are missing or invalid. No warning is logged beyondAPILogger.Log(non-fatal). -
IConvertable.FromDtsSerializationTestpassesReportErrorsbut does not enforce error handling
The delegate is provided but not validated; callers may ignore errors. -
Test.Channelssorting is order-dependent
CompareChannelsis called first (for primary sort), thenChannelOrderComparoris applied. IfChannelOrder.txtis loaded, it overrides the primary sort order. -
TryGetChannelOrderis not idempotent
_channelOrderis cleared on every call. IfChannelOrder.txtis modified during runtime, re-callingTryGetChannelOrder()is required to pick up changes. -
IntervalSecrounding is applied only onget
Begin/Endstore raw values; rounding occurs only when accessed. This may causeBegin != _Begin.Valueduring serialization ifDoRoundOffValuesistrue. -
Test.EqualsignoresGuid,FaultFlags,Modules.Count, andDasTimestamps
OnlyId,Description, andModulesare compared. This is likely a bug or intentional simplification. -
Test.WriteXmlwritesSoftware/SoftwareVersionas attributes, not elements
This is inconsistent withModules/DasTimestamps(which are elements). Ensure consumers expect this. -
Test.ReadXmlusesReadSubtree()for child deserialization
This isolates parsing but may fail if childReadXmlimplementations do not consume all tokens in their subtree. -
No validation for
IntervalSec.Begin >= End
The class does not enforce thatBegin ≤ End. Invalid intervals are allowed. -
Testconstructors do not initializeModulesorDasTimestamps
They are initialized viaProperty<T>defaults (empty lists), but the comment forTest()warnsId/Descriptionare left empty. No other fields are explicitly initialized. -
DasTimestamp.ParentTestis read-only
Set only in constructor; cannot be reassigned later. -
Test.InlineSerializedDatasetter propagates toModules
Modifying this property onTestupdates allModules.InlineSerializedData. This may cause unintended side effects if modules are shared or reused. -
GetUintSafeswallows exceptions silently
ReturnsdefaultValueon failure and logs viaAPILogger, but does not propagate errors. -
Test.SaveTestdeletes backup on success
IfSaveTestfails partway (e.g., after backup but before final save), the backup may be left orphaned. -
IntervalSec.NumberRoundingDecimalPlacesuses aProperty<int>wrapper
This adds indirection but no additional behavior. The underlying value is mutable and not validated. -
Test.Guidis serialized as a string
UsesGuid.ToString()(default format:"D"), which is standard but should be confirmed for compatibility. -
Test.ChannelsincludesCalculatedChannels
These are appended toChannelsalongside regularChannels. Ensure consumers distinguish them if needed. -
DasTimestampusesCultureInfo("")(invariant culture)
This is appropriate for numeric serialization but may cause issues if XML attributes use locale-specific formatting. -
Test.SaveTestappends metadata to.dtsfile
This assumes the.dtsfile is text-based and supports appending. Binary.dtsfiles may be corrupted. -
Test.SaveTestusesStringWriterwithout specifying encoding
StringWriterdefaults to UTF-16, butfileWriterusesEncoding.Unicode(also UTF-16). This is consistent but unusual. -
Test.SaveTestdoes not validatetestIdordirectory
May throwPathTooLongException,DirectoryNotFoundException, or similar. -
Test.SaveTestdoes not flush or close streams explicitly
Relies onusingblocks, butStreamWriterdisposal may not guarantee immediate disk write. -
Test.SaveTestdoes not handle concurrent access
No locking or atomicity guarantees. -
Test.SaveTestdoes not validate XML output
AssumesWriteXmlsucceeds; no validation of XML well-formedness. -
Test.SaveTestdoes not handlemetaDatabeing malformed XML
Appends rawmetaDatastring; if it is invalid XML, the file may be corrupted. -
Test.SaveTestdoes not handlemetaDatabeing null
String.IsNullOrEmpty(metaData)is not checked before appending. -
Test.SaveTestdoes not handlemetaDatabeing empty
Appendswriter.NewLine + writer(empty) +metaData(empty), resulting in a blank line. -
Test.SaveTestdoes not handlemetaDatacontaining</Test>or</TestSetup>
May interfere withGetMetaDataFromDTSFilelogic. -
Test.SaveTestdoes not handlemetaDatabeing larger than file buffer
May cause out-of-memory issues for very large metadata. -
Test.SaveTestdoes not handlemetaDatabeing encoded differently than UTF-16
Appending non-UTF-16 data may corrupt the file. -
Test.SaveTestdoes not handlemetaDatabeing truncated or incomplete
May leave the file in an inconsistent state. -
Test.SaveTestdoes not handlemetaDatabeing corrupted or malformed
May cause downstream parsing errors. -
Test.SaveTestdoes not handlemetaDatabeing duplicated
May cause duplicate metadata sections. -
**
Test.SaveTest