Files
2026-04-17 14:55:32 -04:00

2.7 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.CommonCore/Attributes/VersionAttribute.cs
2026-04-16T02:14:13.867408+00:00 Qwen/Qwen3-Coder-Next-FP8 1 97df6c62ae44caee

Attributes

1. Purpose

This module defines a custom .NET attribute, VersionAttribute, used to annotate types (e.g., classes, interfaces, structs) with an explicit version number. Its role is to enable runtime version metadata inspection—typically for serialization compatibility checks, schema evolution, or API versioning—by attaching a compile-time or design-time version identifier to types in the DTS.CommonCore library.

2. Public Interface

  • class VersionAttribute : Attribute
    A custom attribute class for associating an integer version with a type.
    • Constructor: VersionAttribute(int version)
      Initializes the attribute with the specified version.
    • Property: int Version { get; }
      Gets the version number supplied during construction. Read-only after initialization.

3. Invariants

  • Version is immutable after construction: the setter is private, so it can only be assigned in the constructor.
  • The version parameter passed to the constructor must be a valid int; no validation is performed (e.g., no enforcement of non-negativity or upper bound).
  • The attribute is intended for use on types (as per .NET AttributeUsage defaults), though no explicit AttributeUsage declaration is present—this means it applies to all program elements by default (including assemblies, modules, parameters, etc.), per .NET conventions.

4. Dependencies

  • Dependencies: Only depends on System (specifically System.Attribute). No external or project-specific dependencies.
  • Depended on by: Inferred from the namespace (DTS.Common.Attributes) and naming—likely consumed by reflection-based tooling (e.g., serializers, migration frameworks, or API gateways) within the broader DTS.CommonCore codebase, though no direct consumers are visible in this file.

5. Gotchas

  • Missing AttributeUsage: The attribute lacks an explicit [AttributeUsage(...)] declaration. By default, it can be applied to any program element (not just types), which may be unintended. If intended only for types, this is a potential source of misuse.
  • No version semantics defined: The attribute stores an int but does not enforce or document what the version represents (e.g., major.minor, schema revision, or internal counter). Consumers must infer semantics externally.
  • No version comparison helpers: The attribute provides no methods (e.g., CompareTo, IsCompatibleWith)—consumers must implement their own version logic.
  • None identified from source alone.