7.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||
|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T03:29:41.596274+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 3f95f5cfcf14dbc2 |
SystemInformation
Documentation: System Information Module (DTS.Common.Licensing.SystemInformation)
1. Purpose
This module provides static accessors to retrieve hardware-identifying information from the local Windows machine using WMI (Windows Management Instrumentation) and .NET environment APIs. It is part of the licensing subsystem and is intended to supply stable, hardware-based identifiers (e.g., motherboard serial, CPU ID, system UUID) for machine fingerprinting or license validation. The module is read-only and defensive: all property getters return empty strings on failure instead of throwing exceptions, ensuring robustness in constrained or non-standard environments.
2. Public Interface
All types are static classes; no instantiation is required.
| Type | Member | Signature | Behavior |
|---|---|---|---|
MachineInfo |
MachineName |
public static string MachineName { get; } |
Returns the network name of the machine via Environment.MachineName. Returns "" on any exception. |
ComputerSystemInfo |
SystemID |
public static string SystemID { get; } |
Returns the UUID of the computer system product (from Win32_ComputerSystemProduct.UUID). Returns "" on any exception. |
MainBoardInfo |
SerialNumber |
public static string SerialNumber { get; } |
Returns the serial number of the baseboard (motherboard) (from Win32_BaseBoard.SerialNumber). Returns "" on any exception. |
ProcessorInfo |
ProcessorID |
public static string ProcessorID { get; } |
Returns the ProcessorID field of the first processor (from Win32_Processor.ProcessorID). Returns "" on any exception. |
SystemInformationXSD |
XSD |
public static string XSD { get; } |
Returns a hardcoded XML Schema Definition (XSD) string for validating a SysInfo XML document containing the above fields. |
Note
: All getters are eagerly evaluated on first access and cached internally (via static field initialization or static property getter logic). Subsequent accesses reuse the result unless the underlying WMI query is re-executed (see Gotchas).
3. Invariants
- Non-null return values: All public properties return either a non-empty string (if WMI/Environment data is successfully retrieved) or
""(empty string) on failure. No property ever returnsnull. - No side effects: Property getters are idempotent per call, but due to static
ManagementObjectSearcherfields, repeated access may reuse cached WMI results (see Gotchas). - Windows-only dependency: All WMI-based properties (
SystemID,SerialNumber,ProcessorID) assume Windows and rely onSystem.Management. Behavior on non-Windows platforms is undefined (but likely to return""due to exception handling). - Schema consistency: The
XSDstring defines a fixed schema for aSysInfoXML element containing exactly four child elements (MainBoardSerialNumber,ProcessorID,SystemID,MachineName) and two attributes (Version,SystemInformationGuid). The order of child elements is fixed.
4. Dependencies
| Dependency | Usage |
|---|---|
System.Environment (mscorlib) |
Used by MachineInfo.MachineName to fetch machine name. |
System.Management (System.Management.dll) |
Required for all WMI-based properties (ComputerSystemInfo.SystemID, MainBoardInfo.SerialNumber, ProcessorInfo.ProcessorID). |
System.Linq (System.Core.dll) |
Used via LINQ extension methods (OfType<T>(), FirstOrDefault()) to safely extract WMI results. |
System.Collections.Generic (System.Core.dll) |
Used for ManagementObjectSearcher.Get() result enumeration. |
Depended on by:
This module is part of DTS.Common.Licensing, implying it is consumed by licensing validation logic (e.g., to generate or verify machine fingerprints). No direct reverse dependencies are visible in the provided source.
5. Gotchas
-
WMI query execution is not lazy per access:
ManagementObjectSearcherinstances are static fields, initialized once at type initialization. Each property getter callssystemSearcher.Get()(or equivalent) on every access, meaning repeated calls toProcessorInfo.ProcessorIDwill re-execute the WMI query each time. This is inefficient and may cause performance issues if called frequently. Consider caching the first result (e.g., viaLazy<T>or a static field) if repeated access is expected. -
Win32_*WMI classes are Windows-specific:
On non-Windows platforms (e.g., via .NET Core on Linux/macOS),System.Managementmay not be available or may throw exceptions. All properties will return"", but this behavior is not guaranteed across all environments. -
ProcessorIDmay be empty or non-unique:
TheWin32_Processor.ProcessorIDfield is not guaranteed to be populated on all systems (e.g., virtual machines, some OEM hardware). It may be empty or fall back to a placeholder value. The code does not validate uniqueness or consistency across processors. -
SystemIDvs.UUIDambiguity:
The WMI classWin32_ComputerSystemProduct.UUIDis used forSystemID. While commonly stable, UUIDs can be reset (e.g., BIOS reset, VM cloning) or duplicated in some virtualized environments. -
No validation of WMI field presence:
The code assumes the WMI properties (UUID,SerialNumber,ProcessorID) exist and are non-null. If a property is missing from the WMI result (e.g., due to driver issues),["FieldName"]may throw aNullReferenceException, which is caught and returns"". This is safe but obscures the root cause. -
SystemInformationXSD.XSDis hardcoded and immutable:
The schema string is constant at compile time. There is no mechanism to update or version the schema dynamically. TheVersionandSystemInformationGuidattributes are defined in the schema but not used by any code in this module. -
No thread-safety guarantees:
WhileManagementObjectSearcheris generally thread-safe for concurrent reads, the module does not document or enforce thread-safety. Concurrent access to these properties is likely safe but not guaranteed by design. -
No cleanup of WMI resources:
ManagementObjectSearcherimplementsIDisposable, but none of the searchers are disposed. This may lead to resource leaks in long-running processes (e.g., services), thoughManagementObjectSearcherinternally manages native handles and may mitigate this.
Recommendation for future refactoring: Cache results on first access using
Lazy<string>and ensure proper disposal of WMI resources if repeated access is common.