{
  "id": 21757058,
  "title": "Obfuscating MessagePack contracts",
  "url": "https://urgent.news/2026/11/25/obfuscating-messagepack-contracts",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-25T08:11:16.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/zero_heartbeat_06a3625d7a/obfuscating-messagepack-contracts-9d6"
  },
  "original_language": "en",
  "account": "Two MessagePack serialization styles exist: integer keys and string keys. Integer keys use numeric indices as keys, making them rename-safe and more compact. String keys use property names as keys, making the names part of the contract. MessagePack-CSharp uses different serialization formats for these styles. Obfuscating the classes using integer keys preserves the original names and allows for safe renaming. However, obfuscating classes with string keys breaks compatibility, as renamed names no longer match the serialized keys, leading to data loss. Unit tests may not detect this issue, as they run in the same process and see updated names. Explicit string keys do not offer any additional protection; they simply store the original names in the assembly metadata. In Nebula's configuration, entire assemblies can be marked for full renaming and protection, with specific types exempted for string key usage or contractless serialization.",
  "summary": "Most advice about obfuscating serialized types is a single warning: do not rename your DTOs, the names are the contract. That is true for System.Text.Json , Newtonsoft.Json , and DataContract — the member name is literally the key written to the wire. MessagePack-CSharp is more interesting, because it has two contract styles that behave in opposite ways . One never puts a member name on the wire…",
  "key_points": [
    "MessagePack has integer and string key serialization styles",
    "Integer keys preserve original names, allowing safe renaming",
    "String key obfuscation breaks compatibility, causing data loss"
  ],
  "editors_take": "Choosing integer keys over string keys allows developers to use obfuscation without risking data loss from mismatched property names during the renaming process.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}