# Helpers

Utility classes for token generation, observable collections, type metadata, password security, and async patterns.

## Key Files

- **`AcCharsGenerator.cs`** — Random token/password generation from predefined char pools (`Letters`, `Numbers`, `LettersAndNumbers`). `NewToken()` (8-12 chars), `NewPassword()` (configurable length).
- **`AcObservableCollection.cs`** — Thread-safe `ObservableCollection<T>` with batch updates (`BeginUpdate()`/`EndUpdate()`), `SynchronizationContext` capture for UI thread marshalling (Blazor), `PopulateFromJson()`, `SortAndReplace()`.
- **`ConstHelper.cs`** — Reflection-cached lookup of `const int` field names by value. Used for debug/logging to show human-readable constant names.
- **`JsonUtilities.cs`** — Central type metadata and detection utilities:
  - Pre-cached `Type` handles for primitives, generics, collections
  - `FrozenSet<Type>` for fast primitive checks
  - `IsPrimitiveOrStringFast()`, `IsGenericCollectionType()`, `IsDictionaryType()`, `GetCollectionElementType()`
  - `DetectSerializerType()` — auto-detect JSON vs Binary from bytes/string
  - UTF8 buffer pool: `RentUtf8Buffer()`, `ReturnUtf8Buffer()`
  - String escaping: `NeedsEscaping()`, `WriteEscapedString()`
- **`PasswordHasher.cs`** — PBKDF2-HMAC-SHA512 with 10,000 iterations. **Critical: do not modify `GenerateDynamicSalt()` or `GenerateFinallySalt()` — login will break.** Format: `$bcrypt$v=1$salt=...base64...$hash=...base64...`
- **`PropertyHelper.cs`** — `CopyPublicValueTypeProperties<TSource, TDest>()` for DTO/entity mapping via reflection.
- **`TaskHelper.cs`** — `WaitTo()`/`WaitToAsync()` (poll predicate with timeout using `PeriodicTimer`), `Forget()` (fire-and-forget), `RunOnThreadPool()`.
