98 lines
5.5 KiB
Markdown
98 lines
5.5 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Users/User.cs
|
||
|
|
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Users/ITagAware.cs
|
||
|
|
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Users/Tags.cs
|
||
|
|
generated_at: "2026-04-16T04:30:38.280273+00:00"
|
||
|
|
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "f22aee5e7f816592"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Users
|
||
|
|
|
||
|
|
## Documentation: `User` Class and Related Tag Infrastructure
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 1. Purpose
|
||
|
|
This module provides foundational data structures for handling *tag-aware* entities—specifically, the `User` class, which represents a single user in the system and inherits tag-related functionality from `TagAwareBase`. Tags are metadata labels (ID + text) used to categorize or annotate entities; they are immutable in structure (no delete/modify operations, only add) and stored in a binary blob (`TagsBlobBytes`) for efficient serialization/deserialization. The module supports importing user data (and by extension, other tag-aware entities) from database records via `IDataRecord`, and enables cloning of tag definitions.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 2. Public Interface
|
||
|
|
|
||
|
|
#### `class User : TagAwareBase`
|
||
|
|
- **Inherits** all members of `TagAwareBase` (see below).
|
||
|
|
- **No additional public members** declared in the provided source.
|
||
|
|
- **Purpose**: Encapsulates a single user; tag-related behavior is inherited.
|
||
|
|
|
||
|
|
#### `interface ITagAware`
|
||
|
|
- **Empty interface**.
|
||
|
|
- **Purpose**: Marker interface for classes that support tagging. No methods or properties defined.
|
||
|
|
|
||
|
|
#### `abstract class TagAwareBase : DbTimeStampBase`
|
||
|
|
*(Note: `DbTimeStampBase` is referenced but not defined in the provided source—its members are unknown.)*
|
||
|
|
- **`public int[] TagIDs { get; set; }`**
|
||
|
|
- Gets/sets an array of integer tag IDs associated with the entity.
|
||
|
|
- Setter is null-safe: assigns `new int[0]` if `value` is `null`.
|
||
|
|
- **`public byte[] TagsBlobBytes { get; set; }`**
|
||
|
|
- **Getter**: Converts `TagIDs` to a `byte[]` via `Buffer.BlockCopy` (int array → bytes).
|
||
|
|
- **Setter**: Attempts to reconstruct `TagIDs` from a `byte[]` by interpreting bytes as `int` values.
|
||
|
|
- Silently returns if `value.Length < sizeof(int)` (i.e., < 4 bytes).
|
||
|
|
- Silently ignores exceptions during `Buffer.BlockCopy` (no rethrow or logging—commented-out `APILogger.Log` suggests intentional suppression).
|
||
|
|
|
||
|
|
#### `class Tags.Tag : ICloneable`
|
||
|
|
*(Nested within `Tags` class)*
|
||
|
|
- **`public int ID { get; set; }`**
|
||
|
|
- Unique identifier for the tag.
|
||
|
|
- **`public string Text { get; set; }`**
|
||
|
|
- Human-readable label for the tag.
|
||
|
|
- **`public bool IsObsolete { get; set; }`**
|
||
|
|
- Indicates whether the tag is deprecated (but not deleted).
|
||
|
|
- **`public Tag(Tag copy)`**
|
||
|
|
- Copy constructor: initializes fields from another `Tag` instance.
|
||
|
|
- **`public Tag(IDataRecord reader)`**
|
||
|
|
- Constructor that populates the `Tag` from a database record.
|
||
|
|
- Reads fields via `DbOperations.Tags.TagFields` enum (values: `TagId`, `Obsolete`, `TagText`).
|
||
|
|
- Silently ignores exceptions during parsing (commented-out logging).
|
||
|
|
- **`public object Clone()`**
|
||
|
|
- Returns a shallow copy of the `Tag` via the copy constructor.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 3. Invariants
|
||
|
|
- **`TagIDs` is never `null`**: The setter enforces `value ?? new int[0]`.
|
||
|
|
- **`TagsBlobBytes` ↔ `TagIDs` consistency**:
|
||
|
|
- Getter always produces a `byte[]` of length `TagIDs.Length * sizeof(int)`.
|
||
|
|
- Setter *attempts* to restore `TagIDs` from `TagsBlobBytes`, but may silently fail (e.g., if `value.Length` is not a multiple of `sizeof(int)` or contains invalid data).
|
||
|
|
- **Tag immutability constraints**:
|
||
|
|
- Tags are *not* deletable or editable (per `Tags.cs` summary). Only new tags may be added.
|
||
|
|
- `IsObsolete` is a flag but does not imply deletion; obsolete tags remain in the system.
|
||
|
|
- **`DbTimeStampBase` inheritance**: `TagAwareBase` inherits from `DbTimeStampBase` (not shown), implying timestamp-related fields (e.g., `Created`, `Modified`) are expected but not defined here.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 4. Dependencies
|
||
|
|
- **Internal dependencies**:
|
||
|
|
- `DbOperations.Tags.TagFields` enum (used in `Tags.Tag` constructor).
|
||
|
|
- `DbTimeStampBase` (base class of `TagAwareBase`; not provided).
|
||
|
|
- `APILogger` (referenced in commented-out logging statements; assumed external).
|
||
|
|
- **External dependencies**:
|
||
|
|
- `System` (for `Buffer`, `Exception`, `ICloneable`).
|
||
|
|
- `System.Data` (for `IDataRecord`).
|
||
|
|
- **Depended upon by**:
|
||
|
|
- `User` (direct consumer of `TagAwareBase`).
|
||
|
|
- Likely other tag-aware entities (e.g., `Project`, `Asset`) not included in this source set.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 5. Gotchas
|
||
|
|
- **Silent failure in `TagsBlobBytes` setter**: Exceptions during deserialization are caught and ignored—no error is surfaced to callers. This may mask data corruption or schema mismatches.
|
||
|
|
- **No validation of `TagIDs`**: The `TagIDs` array may contain IDs that do not correspond to valid tags (no cross-reference validation).
|
||
|
|
- **`IsObsolete` is not enforced**: While tags *can* be marked obsolete, the system does not prevent their use (e.g., assignment to users).
|
||
|
|
- **`TagAwareBase` inherits from `DbTimeStampBase`**: Behavior of timestamp fields is undefined here; assume they exist but require external documentation.
|
||
|
|
- **`Tags` class is not a collection**: Despite its name, `Tags` only defines the `Tag` inner class—no methods for managing a set of tags (e.g., add/remove/lookup). Tag management is implied to occur elsewhere.
|
||
|
|
- **No thread-safety guarantees**: `TagsBlobBytes` and `TagIDs` use simple field access; concurrent modification risks exist if shared across threads.
|
||
|
|
|
||
|
|
*None identified beyond the above.*
|