AyCode.Core/AyCode.Core.Serializers.Sou...
Loretta 17daf0fef2 Document AcBinary wire format, sync docs, update conventions
- Add BINARY_FORMAT.md: full AcBinary wire format spec (markers, encoding, options, protocol, interactions)
- Reference BINARY_FORMAT.md from GLOSSARY.md, Binaries/README.md, and Serializers/Binaries/README.md; add new glossary terms
- Clarify and expand config options tables to match new doc
- Add/clarify LLM maintenance rules: always sync .md files with code, auto-fix discrepancies
- Update root README.md: AyCode.Core targets .NET 9, not 10; stress doc/code sync
- Add code reuse and doc sync conventions to copilot-instructions.md and CONVENTIONS.md
- Add docs/ folder and BINARY_FORMAT.md to solution as Solution Items
- Minor clarifications and cross-links in ARCHITECTURE.md and other docs
2026-03-29 09:11:57 +02:00
..
AcBinarySourceGenerator.cs Optimize scan codegen with compile-time property checks 2026-03-10 18:35:25 +01:00
AyCode.Core.Serializers.SourceGenerator.csproj Add AcBinary Source Generator for fast serialization 2026-01-06 08:58:34 +01:00
README.md Document AcBinary wire format, sync docs, update conventions 2026-03-29 09:11:57 +02:00

README.md

AyCode.Core.Serializers.SourceGenerator

Roslyn incremental source generator that produces optimized IGeneratedBinaryWriter and IGeneratedBinaryReader implementations for types marked with [AcBinarySerializable]. Eliminates runtime reflection on serialization hot paths.

Targets netstandard2.0 (required for Roslyn analyzers/generators).

Key Files

  • AcBinarySourceGenerator.cs — Single-file IIncrementalGenerator (~2100 lines). Generates:
    • {ClassName}_GeneratedWriter — Per-type writer with ScanObject() + WriteProperties() methods. Handles primitives, strings (with interning), collections, dictionaries, complex nested types, and polymorphic objects.
    • {ClassName}_GeneratedReader — Per-type reader with ReadProperties() method.
    • ModuleInitializer — Auto-registers all generated writers/readers at startup.
    • Circular reference detection with ACBIN001 diagnostic warning.

Feature Flags

The [AcBinarySerializable] attribute supports per-type feature control:

  • enableMetadata — Property hash metadata for cross-type deserialization
  • enableIdTracking — IId-based reference tracking
  • enableRefHandling — General reference tracking
  • enableInternString — String interning/deduplication

Disabled features eliminate corresponding code blocks from generated output (zero dead code).

Dependencies

Dependency Purpose
Microsoft.CodeAnalysis.CSharp Roslyn syntax/semantic APIs
Microsoft.CodeAnalysis.Analyzers Analyzer best practices