3.7 KiB
3.7 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T02:11:01.276588+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 96c94c51da2a1b2d |
Static
1. Purpose
This module provides a mechanism to associate custom, non-default field sizes with enum values representing channel fields in the MMETables.MMEPossibleChannelsFields enumeration. It enables runtime retrieval of field-specific size metadata via a custom attribute (CustomChannelFieldSizeAttribute) and extension methods, supporting scenarios where the default size inference (e.g., based on underlying type or convention) is insufficient or incorrect.
2. Public Interface
CustomChannelFieldSizeAttribute(int size)
Constructor. Creates an attribute instance with the specified field size.sizemust be non-negative (enforced by caller; no validation in constructor).int Size { get; }
Property. Returns the field size stored in the attribute. Read-only after construction.int GetFieldSize(MMETables.MMEPossibleChannelsFields field)
Extension method. Retrieves the field size for a givenMMEPossibleChannelsFieldsenum value by inspecting itsCustomChannelFieldSizeAttribute. ThrowsNullReferenceExceptionif the attribute is not applied to the enum value (since.Sizeis accessed on anullreference returned byGetAttribute<>()).TAttribute GetAttribute<TAttribute>(this Enum value)
Extension method. Returns the first (and expected only) custom attribute of typeTAttributeapplied to the enum value, ornullif none exists. Uses reflection to inspect the enum field’s attributes.
3. Invariants
CustomChannelFieldSizeAttributeis only intended for use onMMETables.MMEPossibleChannelsFieldsenum members.- The
Sizeproperty must be set at construction and remains immutable thereafter. GetFieldSizeassumes exactly oneCustomChannelFieldSizeAttributeper enum member; behavior is undefined if multiple attributes are applied (thoughSingleOrDefault()would return the first if duplicates exist, which is invalid per attribute semantics).GetAttribute<TAttribute>returnsnullif no attribute of typeTAttributeis present on the enum value.
4. Dependencies
- Internal dependencies:
MMETables.MMEPossibleChannelsFieldsenum (fromMMETablesnamespace—external to this file but referenced inGetFieldSize).- Standard .NET reflection APIs (
System.Type,System.Reflection.FieldInfo,System.Linq.Enumerable).
- No external NuGet or third-party dependencies beyond the base class library.
- Dependent modules: Any code that needs to retrieve field sizes for
MMEPossibleChannelsFieldsvalues—likely storage or serialization components dealing with channel data.
5. Gotchas
- Null reference risk:
GetFieldSizewill throwNullReferenceExceptionifCustomChannelFieldSizeAttributeis not applied to the queried enum member (sinceGetAttribute<>()returnsnull, and.Sizeis dereferenced unconditionally). Callers must ensure the attribute is present or guard againstnull. - No validation on
size: The constructor accepts anyint, including negative values. No runtime checks enforce valid size constraints (e.g.,size ≥ 0). - Reflection overhead:
GetAttribute<TAttribute>uses reflection on every call; not suitable for hot paths without caching. - Ambiguity in
MMETablesnamespace: TheMMETables.MMEPossibleChannelsFieldstype is referenced but not defined here; its actual definition and available members are unknown from this file alone. - No XML documentation: The source contains no comments; behavior is inferred solely from code structure.