docs: add ADR-012 and MessagePack serialization guidelines
- Update design.md with MessagePack component requirements - Add ADR-012 to architecture.md regarding public type requirements - Add MessagePackAnalyzer to OECS.csproj for compile-time validation
This commit is contained in:
@@ -334,3 +334,32 @@ no parallel scheduling.
|
||||
|
||||
- Consumers must be on .NET 8 or later.
|
||||
- Can use `ref` returns, `readonly struct`, and other modern C# features.
|
||||
|
||||
---
|
||||
|
||||
## ADR-012: Public Types Required for MessagePack Serialization
|
||||
|
||||
**Status:** Accepted
|
||||
|
||||
**Context:** Component types must be serializable by MessagePack-CSharp. The
|
||||
library imposes constraints on type design.
|
||||
|
||||
**Decision:** Component types must be `public` and annotated with
|
||||
`[MessagePackObject]` and `[Key]` attributes. The `MessagePackAnalyzer` NuGet
|
||||
package is included for compile-time validation.
|
||||
|
||||
**Rationale:**
|
||||
|
||||
- MessagePack-CSharp requires public types for its dynamic formatter generation
|
||||
and source-generated formatters.
|
||||
- `MessagePackAnalyzer` provides AOT-safe source-generated formatters (critical
|
||||
for Unity IL2CPP) and catches misconfigured types at compile time.
|
||||
- Indexed integer keys (`[Key(0)]`) produce the fastest and most compact
|
||||
serialization, which aligns with the ECS performance goal.
|
||||
|
||||
**Consequences:**
|
||||
|
||||
- Component authors cannot use `private` or `internal` types.
|
||||
- The `MessagePackAnalyzer` package is a compile-time dependency.
|
||||
- `[Key]` indices should be sequential starting from 0 to avoid null
|
||||
placeholders in the binary output.
|
||||
|
||||
Reference in New Issue
Block a user