serialization

Compares .NET serialization formats for compatibility and performance.

71|10|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/wshaddix/dotnet-skills --skill serialization-wshaddix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: serialization
Source: https://github.com/wshaddix/dotnet-skills/tree/main/skills/serialization
Command: npx skills add https://github.com/wshaddix/dotnet-skills --skill serialization-wshaddix

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the complexities of choosing and implementing efficient, AOT-compatible serialization formats in .NET applications, preventing common pitfalls and optimizing performance.

Core Features & Use Cases

  • Format Comparison: Understand the trade-offs between JSON (System.Text.Json, Newtonsoft.Json), Protocol Buffers, and MessagePack for various scenarios.
  • AOT Compatibility: Learn how to implement source-generated serialization with System.Text.Json and MessagePack for Native AOT deployments.
  • Wire Format Best Practices: Implement robust serialization strategies for distributed systems, including versioning and tolerant readers.
  • Use Case: You need to select the best serialization format for a high-throughput microservice communication and ensure it works with Native AOT. This Skill guides you through Protobuf and System.Text.Json source generators.

Quick Start

Use the serialization skill to compare JSON, Protobuf, and MessagePack for AOT compatibility.

Frequently Asked Questions about serialization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the best .NET serialization format for Native AOT compatibility?

For Native AOT compatibility, schema-based formats like Protocol Buffers or source-generated System.Text.Json are best. They avoid runtime reflection, ensuring efficient ahead-of-time compiled serialization without dynamic code generation issues.

How do I migrate from Newtonsoft.Json to System.Text.Json source generators?

To migrate from Newtonsoft.Json to System.Text Json source generators, configure context classes for your types. This enables compile-time serialization generation, improving performance and ensuring AOT compatibility while replacing runtime reflection.

Protocol Buffers vs MessagePack: which should I use for .NET microservices?

Protocol Buffers offer strict schema versioning and cross-language support, while MessagePack provides compact binary serialization with source generator support. Choose Protobuf for contract-first services and MessagePack for high-throughput internal communication.

Why does reflection-based serialization break in .NET Native AOT deployments?

Reflection-based serialization breaks in Native AOT because the trimmer removes metadata and dynamic code paths that runtime reflection relies on. Source generators solve this by emitting compile-time serialization logic explicitly.

When do I need tolerant reader patterns for .NET wire format compatibility?

You need tolerant reader patterns for wire format compatibility when distributing systems evolve independently. This approach allows deserialization to ignore unknown fields, preventing failures when older clients receive newer message versions.

Does Akka.NET support custom Protocol Buffers or MessagePack serialization?

Yes, Akka.NET supports custom serialization. Implementing Protocol Buffers or MessagePack allows you to optimize actor message payloads, achieving better performance and Native AOT compatibility compared to default serializers.