AyCode.Core/AyCode.Core/Extensions/README.md

1.5 KiB

Extensions

Extension methods for collections, serialization, and common utilities.

Key Files

  • CollectionExtensions.csIList<T> extensions for IId<Guid> entities: UpdateCollection() (add/update/remove with TrackingState), FindIndex(), BinarySearch(), safe indexing.
  • CollectionExtensionsInt.cs — Same as above but for IId<int> entities.
  • SerializeObjectExtensions.cs — Unified serialization API via extension methods:
    • .ToJson(), .JsonTo<T>() — JSON serialization (Newtonsoft + custom HybridReferenceResolver with Base62 semantic IDs)
    • .ToBinary(), .BinaryTo<T>() — Binary serialization
    • .CloneTo<TDest>(), .CopyTo() — Object cloning
    • .JsonToChain<T>(), .BinaryToChain<T>() — Multi-deserialize chains
    • .BinaryToMerge<T>() — IId-aware collection merging
    • Includes: JsonReferencePostProcessor (strips unreferenced $id), PooledStringWriter (StringBuilder pooling)
  • EnumExtensions.csGetDisplayName() via DisplayAttribute reflection.
  • ExceptionExtensions.csGetCategoryAndMemberNameFromStackTraceString() for structured caller info extraction.
  • GuidExtensions.csIsNullOrEmpty() for Guid and Guid? with [NotNullWhen] annotations.

LLM Maintenance: If you modify code in this folder, update this README to reflect the changes. If you notice the README content does not match the current code, automatically update the README to match the code.