# AyCode.Core

@project {
  type = "framework"
}

Core library for the AyCode platform. Targets .NET 9 (set in `AyCode.Core.targets`). Provides serialization (Binary, JSON, Toon), compression, logging, validation, and shared utilities.

## Documentation

| Document | Topic |
|---|---|
| `BINARY_FORMAT.md` | Binary wire format spec (stream layout, type markers) |
| `BINARY_FEATURES.md` | Binary features (interning, ref tracking, property ordering) |
| `BINARY_OPTIONS.md` | Binary configuration options & presets |
| `LOGGING.md` | Logging framework (hierarchy, config, ILogger bridge) |

## Folder Structure

| Folder | Purpose | README |
|---|---|---|
| [`Compression/`](Compression/README.md) | Brotli, GZip, LZ4 compression (pure managed, WASM-compatible) | [README](Compression/README.md) |
| [`Consts/`](Consts/README.md) | Project-wide constants, error codes, regex validation, environment config | [README](Consts/README.md) |
| [`Enums/`](Enums/README.md) | Shared enums: AppType, MessageContextType, TrackingState | [README](Enums/README.md) |
| [`Extensions/`](Extensions/README.md) | Collection merge/sync, serialization extensions, utility extensions | [README](Extensions/README.md) |
| [`Helpers/`](Helpers/README.md) | Token generation, observable collections, JSON utilities, password hashing, task helpers | [README](Helpers/README.md) |
| [`Interfaces/`](Interfaces/README.md) | Core interfaces: IId&lt;T&gt;, IForeignKey, IAcSerializableToJson | [README](Interfaces/README.md) |
| [`Loggers/`](Loggers/README.md) | Custom logging framework with MS.Extensions.Logging integration | [README](Loggers/README.md) |
| [`Serializers/`](Serializers/README.md) | Serialization framework: Binary, JSON, Toon formats on shared infrastructure | [README](Serializers/README.md) |

## Root Files

- **`AcDomain.cs`** — Singleton for process-level state: process name, build type detection (`IsDeveloperVersion`/`IsProductVersion`), processor count, thread-safe unique ID generators (`NextUniqueInt32`, `NextUniqueInt64`).

## Dependencies

| Dependency | Purpose |
|---|---|
| `AyCode.Utils` | Shared utilities (project reference) |
| `AyCode.Core.Serializers.SourceGenerator` | Binary serializer source generation (analyzer) |
| `MessagePack` | MessagePack serialization |
| `Newtonsoft.Json` | JSON serialization (legacy, alongside System.Text.Json) |
| `Microsoft.Extensions.Configuration.*` | appsettings.json + environment variable support |
| `Microsoft.Extensions.Logging.Abstractions` | Logging abstractions |
