53 lines
2.5 KiB
Markdown
53 lines
2.5 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- Common/DTS.CommonCore/Attributes/VersionAttribute.cs
|
||
|
|
generated_at: "2026-04-16T12:02:23.720037+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "97df6c62ae44caee"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Documentation: VersionAttribute
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
`VersionAttribute` is a custom attribute class that allows developers to annotate code elements (classes, methods, properties, etc.) with an integer version number. It provides a simple mechanism for versioning components within the DTS system, which may be used for tracking API evolution, serialization compatibility, or feature versioning.
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### `VersionAttribute` Class
|
||
|
|
**Namespace:** `DTS.Common.Attributes`
|
||
|
|
**Base Class:** `System.Attribute`
|
||
|
|
|
||
|
|
#### Constructor
|
||
|
|
```csharp
|
||
|
|
public VersionAttribute(int version)
|
||
|
|
```
|
||
|
|
Creates a new instance of the attribute with the specified version number. The `version` parameter is stored in the read-only `Version` property.
|
||
|
|
|
||
|
|
#### Properties
|
||
|
|
```csharp
|
||
|
|
public int Version { get; private set; }
|
||
|
|
```
|
||
|
|
Returns the version number specified when the attribute was instantiated. This property is read-only externally; it can only be set via the constructor.
|
||
|
|
|
||
|
|
## 3. Invariants
|
||
|
|
|
||
|
|
- The `Version` property is immutable after construction (private setter).
|
||
|
|
- The `Version` value is always an `int`; no null state is possible since `int` is a value type.
|
||
|
|
- No constraints are enforced on the range of `version` (negative values, zero, and positive values are all accepted).
|
||
|
|
|
||
|
|
## 4. Dependencies
|
||
|
|
|
||
|
|
### This module depends on:
|
||
|
|
- `System` — Provides the `Attribute` base class.
|
||
|
|
- `System.Linq` — Imported but **not used** in the current implementation.
|
||
|
|
|
||
|
|
### What depends on this module:
|
||
|
|
- Cannot be determined from the source file alone. This attribute is defined in `DTS.CommonCore`, suggesting it is part of a core utilities library that other modules likely reference.
|
||
|
|
|
||
|
|
## 5. Gotchas
|
||
|
|
|
||
|
|
- **Unused import:** The `using System.Linq;` directive is present but not utilized in the code. This may be leftover from refactoring or template code.
|
||
|
|
- **No `AttributeUsage` declaration:** The attribute lacks an `[AttributeUsage]` specification, meaning it can be applied to any target (classes, methods, assemblies, etc.) with default behavior (allowing multiple instances = false, inherited = true). If specific usage constraints are intended, they are not enforced at the attribute definition level.
|
||
|
|
- **No version validation:** The constructor accepts any integer, including negative values. If semantic versioning or positive-only constraints are expected by consumers, they are not enforced here.
|