# Extensions

Extension methods for collections, serialization, and common utilities.

## Key Files

- **`CollectionExtensions.cs`** — `IList<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.cs`** — `GetDisplayName()` via `DisplayAttribute` reflection.
- **`ExceptionExtensions.cs`** — `GetCategoryAndMemberNameFromStackTraceString()` for structured caller info extraction.
- **`GuidExtensions.cs`** — `IsNullOrEmpty()` for `Guid` and `Guid?` with `[NotNullWhen]` annotations.
