
Serialization
This is a reference guide for picking serialization formats in .NET, with a strong opinion: use schema-based formats like Protobuf or MessagePack over reflection-based ones like Newtonsoft.Json. It walks you through System.Text.Json with source generators for AOT compatibility, shows you how to version Protobuf schemas without breaking old readers, and explains when to use what (gRPC gets Protobuf, caching gets MessagePack, REST APIs get System.Text.Json). The migration section from Newtonsoft is solid, covering the attribute differences and polymorphism gotchas. If you're building distributed systems or planning for Native AOT, the wire compatibility patterns alone are worth reading.
- skills.sh installs
- 596
- GitHub stars
- 1.3K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add aaronontheweb/dotnet-skills --skill serialization --agent claude-codeInstalls into .claude/skills of the current project.
Files
Serialization in .NET
When to Use This Skill
Use this skill when:
- Choosing a serialization format for APIs, messaging, or persistence
- Migrating from Newtonsoft.Json to System.Text.Json
- Implementing AOT-compatible serialization
- Designing wire formats for distributed systems
- Optimizing serialization performance
Schema-Based vs Reflection-Based
| Aspect | Schema-Based | Reflection-Based |
|---|---|---|
| Examples | Protobuf, MessagePack, System.Text.Json (source gen) | Newtonsoft.Json, BinaryFormatter |
| Type info in payload | No (external schema) | Yes (type names embedded) |
| Versioning | Explicit field numbers/names | Implicit (type structure) |
| Performance | Fast (no reflection) | Slower (runtime reflection) |
| AOT compatible | Yes | No |
| Wire compatibility | Excellent | Poor |
Recommendation: Use schema-based serialization for anything that crosses process boundaries.
Format Recommendations
Sponsors
Details
- Repository
- github.com/aaronontheweb/dotnet-skills
- Categories
- Code Review & Quality, .NET & C#
- First seen
- Jun 3, 2026
More from aaronontheweb/dotnet-skills
All 34- Crap Analysis581
- Dotnet Slopwatch580
- Testcontainers Integration Tests579
- Playwright Blazor Testing560
- Dotnet Local Tools550
- Aspire Integration Testing522
- Mjml Email Templates513
- Aspire Service Defaults497
- Aspire Configuration487
- Snapshot Testing484
- Dotnet Devcert Trust457
- Skills Index Snippets456
- Playwright Ci Caching455
- Akka Net Best Practices451
- Mailpit Integration443
- Verify Email Snapshots436
- Akka Hosting Actor Patterns434
- Akka Net Testing Patterns431
- OpenTelemetry NET Instrumentation431
- Akka Net Management430
- Akka Net Aspire Configuration415
- Marketplace Publishing408
- Modern Csharp Coding Standards2.3K
- Csharp Concurrency Patterns1.6K