Skip to content

MessagePack for C# v4.0.0 - #2298

Merged
neuecc merged 188 commits into
masterfrom
v4
Dec 4, 2026
Merged

neuecc merged 188 commits into
masterfrom
v4

Conversation

@neuecc

@neuecc neuecc commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

This is the first preview of v4.

v4 is a ground-up redesign: more than twice the performance, stronger security by default, full Native AOT support, and many new features, including support for C# 14 union types.

The basic API shape is unchanged, and v4 is feature-compatible and wire-compatible with v3 (v3 and v4 read each other’s output). It does, however, contain many breaking changes; see the v4 README and its “Migrating from v3” section before upgrading.

Please report any problems in the Issues.

We will not merge into master until the stable version is released.
Updates will continue on the v4 branch.

@AArnott

AArnott commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

We won't merge into master until the v4 stable release.

What part does the develop branch play in this? Should v4 merge into develop since it isn't being used for anything else at the moment? I think its few unique commits beyond what master has are minor.

@neuecc

neuecc commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Using a develop branch for the development line is not my style, so I think we will stop using develop.

neuecc and others added 14 commits October 1, 2026 17:02
- Codex cross-review rounds 1-25: fixes and regression tests
  (ReviewRound*RegressionTests), member-attribute netstandard factory
  fallback via CreateFormatterWith, ForceSize attribute-only, construction-
  shaped types constructed afresh on populate, element streams share one
  DeserializeState (Reset per element), multi-dimensional array allocation
  guard
- LZ4 / Zstandard frame processors: streaming per-segment encode, resumable
  boundary walk (TryFindMessageEnd position), dictionary support
  (WithLz4Frame(dictionary, id) / WithZstandardFrame(dictionary)) on
  NativeCompressions and the .NET 11 BCL codec
- walker trust tests: differential vs the bindings, CLI-shaped foreign
  frames, hand-built headers

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… benchmark

NonGenericEntry<T>.Deserialize returns the preallocated TrueBox / FalseBox / NilBox for
bool and Nil instead of boxing per call. The typeof(T) checks fold at JIT time so every
other instantiation keeps its plain box. Test covers all six entry points plus the bool?
neighbour.

DisassembleBenchmark: AlternatingTypeBenchmark (int/bool alternation across v4, v3,
Nerdbank, STJ, generic and non-generic), --jit-int32-de / --jit-alt / --jit-ngbox
hot-loops, and ConcurrentDictionary<Type,> rows with results in TypeKeyTableBenchmark.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…globalization, v3 Typeless DateTime

Generator
- ModuleInitializerAttribute polyfill is emitted unless exactly one copy is accessible
  from the compilation (an internal copy in a referenced downlevel assembly used to
  suppress it: CS0122 in a netstandard DTO library + .NET Framework app)
- MsgPack024: C# 9 floor (C# 13 under NET9_0_OR_GREATER); below it the generators emit
  nothing instead of failing inside .g.cs

Core
- DeserializeState/SerializeState.Enter probe TryEnsureSufficientExecutionStack every
  16 levels; ConvertToJson gets its own 500-level limit (object payloads within MaxDepth
  overflowed small threads: ~2.4 KB/level on .NET Framework x64)
- CultureInfo and TimeZoneInfo leave the default chain (payload-driven runtime/OS lookup,
  like System.Type): CultureInfoFormatterFactory / TimeZoneInfoFormatterFactory opt in,
  with predefined-culture-only names, a length cap and all lookup failures as the data
  error
- NativeDateTimeFormatterFactory: v3's Typeless chain wrote DateTime as ToBinary int64;
  README's migration row now composes it and passes allowPrivate: true
- netstandard builds refuse Half/Int128/UInt128/DateOnly/TimeOnly/Rune/NFloat loudly
  (the contractless tier claimed them as empty member maps); Index/Range served on ns2.1
- netstandard ConcurrentDictionary members are rebuilt when a resistant comparer applies
- ArrayFormatter/ArraySegmentFormatter replace a covariant array instead of reusing it
- reflection tier constructs init-only/required classes afresh like the generator
- Typeless ext-100 DateTime body validates the binary value (shared DateTimeBinary)

README: targets and C# requirement, populate contract vs v3, not-on-default-chain types,
Typeless migration row, depth/stack note.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…t9+, AOT nullable scalars, SortedList, v3 parity fixes

Generator
- surrogates a referenced assembly declares for a type of a third assembly are adopted
  into every consumer's generated factory and module initializer
  (ReferencedSurrogateScanner): their registration rode the declaring assembly's
  initializer, which never runs when nothing calls into it, so the consumer saw
  formatter-not-found or a contractless map depending on load order. Two libraries
  claiming one target: neither adopted, MsgPack019. The MsgPack108 analyzer treats an
  adopted target as covered
- README's partial custom formatter (no where-clauses) no longer gets MsgPack012 on
  net9+: the attribute check asks BufferConstraintsGenerator's convention instead of
  the bare syntax; the message names both remedies
- MsgPack104 message: whole-file suppression is the intended answer when the string is
  the formatter's own wire form

Core
- BuiltInFormatterFactory closes Nullable<T> over its scalar set, so DefaultAot serves
  a root int? / DateTime? without MakeGenericType (same formatter type, same wire)
- LoadAnyType retries with v3's mscorlib <-> System.Private.CoreLib spelling swap:
  Typeless written on .NET was unreadable on .NET Framework
- SortedListFormatter reads into arrays, sorts once with the list's comparer and
  inserts ascending (descending keys were O(n^2): 1M entries over a minute); comparer
  failures on mixed keys surface as MessagePackSerializationException
- reflection tier runs the callbacks of a type implementing only v3's
  IMessagePackSerializationCallbackReceiver (name-matched like the attributes)
- Typeless writes anonymous types as the bare contractless map, as v3 did (the ext name
  was a per-compilation ordinal nobody else could load); anonymous backing fields
  (<X>i__Field) are skipped under allowPrivate

README: v3-built packages break under NuGet unification, DefaultOptions row, generic
attributes are net9+, ASP.NET Core packages and registration, System.Text.Json
dependency, element-stream retention for AllowCircularReferences types, surrogate
adoption. FrozenSet string-hash finding refuted (Marvin is per-process random on net9+;
pinned by a test).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…jectAttribute, explicit annotatedOnly, README notes

- dynamic closing of generic [MessagePackObject] formatters moves from every generated
  factory into SourceGeneratedFormatterFactory: generated code registers the open
  formatter definition (RegisterOpenGeneric, with the trimmer told about the
  constructor), Instance closes it at run time, the new StaticInstance never does.
  DefaultAot / DotNetOptimizedAot compose StaticInstance, so a JIT run of the AOT chain
  fails on an unharvested instantiation exactly where the published app would; Default
  keeps the generated formatter (never the reflection tier). No MakeGenericType,
  Activator or IL3050/IL2067 suppression left in generated code
- MessagePackObjectAttribute is sealed (a derived attribute was silently not generated);
  the ported v3 derived-attribute test is excluded per the V3Compat policy
- ReflectionFormatterFactory(bool annotatedOnly) has no default: the parameterless form
  was the contractless tier, which claims collections when composed before Default
- ConvertFromJson uses JsonDocument.Parse, so the net9.0 build no longer references the
  System.Text.Json package (netstandard builds still do)
- IL2090 (not IL2070) is the suppression the legacy-callback lookup needs
- README: TryWrite* smallest vs TryWriteForced* fixed width, drop v3 MsgPack0xx
  suppressions, Lz4BlockArray bytes differ across writers, object-slot strings bypass
  string customization, ConvertToJson has no options overload, DefaultAot never closes
  generics at run time
- v3's doc/ folder removed (its MsgPack00x pages described different rules)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Serialize(IBufferWriter): Flush only on success; the Dispose in a finally committed the span a
  failing formatter had half-written (a PipeWriter sent it ahead of the next message). Doc: bytes a
  large message already flushed before failing stay in the writer
- DeserializeAsync(PipeReader): every failure path hands the read back (size exceeded, truncated,
  boundary-scan error), so the reader is not left "reading in progress"
- Deserialize(Stream, non-seekable): reads at most one byte past MaxBufferedMessageSize instead of
  filling the pool array (a 100 MB cap let 128 MB through)
- LZ4 / Zstandard frames: a declared content size the compressed bytes cannot produce (255:1 for
  LZ4, 128 KB per 4-byte block for zstd) is refused before renting the declared size; a cap above
  Array.MaxLength no longer lets the declaration wrap negative in the int cast
- ZstandardFrameProcessor validates the compression level at construction (the first encoder is
  created eagerly) instead of on the first Serialize
- MessagePack.LZ4 package description leads with WithLz4Frame
- docs: MaxBufferedMessageSize counts compressed bytes (set MaxDecompressedSize too), a processor
  reads a Stream to its end as one message, Zstandard's window cap follows MaxDecompressedSize,
  HashFloodingResistant's covered key types and collection types

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- ForceTypelessFormatter checks the boxed value against the slot type: an unassignable value (a bare primitive where
  an interface is declared, an allowed type that does not implement it) is a MessagePackSerializationException naming
  both types, not an InvalidCastException
- every reflective Invoke (object-slot dispatcher, Typeless serializer, reflection member slots, union cases, the
  reflection constructor and [MessagePackFormatter] activation, legacy callbacks) goes through InvokeUnwrapped, so the
  construction exception surfaces as the typed entry points throw it instead of wrapped in TargetInvocationException
- a module initializer that throws (TypeInitializationException) propagates instead of switching the registry's
  RunModuleConstructor mitigation off for every other assembly in the process
- CompatibilityFallback is raised after the resolver releases its lock; a handler that serializes on another thread
  no longer deadlocks. README: do not serialize from a [ModuleInitializer] or a static constructor
- PresizeHashCapacity counts the 12 bytes a Dictionary/HashSet entry costs beyond the pair (hash code, chain link,
  bucket slot) and replaces PresizeCapacity at every hash-container site; the object formatter's map and the non-generic
  IDictionary formatter, which presized straight from the header (~14x the payload), use it too
- StringInterningFormatterFactory exists on netstandard2.0 (Dictionary<string,string> pool, parameterless constructor
  only) and the default pool below net9 uses the flooding-resistant string comparer, as the netstandard builds run on
  Mono/IL2CPP with deterministic string hashing
- docs: CollectionFormatters populate header and README state which collections keep element instances (T[], List<T>,
  array views, multi-dimensional arrays; everything else is cleared and re-added); netstandard-only DTO libraries
  reroute net9+ hosts to the Compatible buffers (multi-target, CompatibilityFallback, ThrowOnLegacyFormatter);
  AllowedTypes must list Guid/DateTime/enums/collections too
- nullable warnings on the Typeless DateTime/object serializers, cref ambiguity on TryFindMessageEnd
- ForeignSurrogateTests no longer asserts the surrogate assembly's initializer has not run: the CLR activates that module
  when any method referencing its types is compiled, so the canary was schedule-dependent (failing on HEAD too)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- generator harvests the formatters InterfaceLookupFormatter and InterfaceGroupingFormatter resolve themselves
  (IGrouping<K,V>, IEnumerable<V>), so ILookup / IGrouping members work on the AOT chains and under Native AOT
- ObjectFallbackFormatterFactory.Instance is a RequiresDynamicCode/RequiresUnreferencedCode property (was a field)
  and its constructor, ReflectionUnionFormatterFactory<T>, ReflectionUnionFormatter, ReflectionObjectFormatter and
  TypelessFormatter constructors carry the annotations: composing them with DefaultAot warns instead of failing at run
  time on Native AOT. The factories that construct them suppress at the one gated site
- RequiresUnreferencedCode next to RequiresDynamicCode on GenericFormatterFactory (Instance and constructor),
  GenericFormatterFactoryBase, GenericEnumAsStringFormatterFactory; TypeFormatterFactory gets it alone. A trimmed JIT
  app now sees the warning for the constructor probes trimming removes silently
- reflection tier parity with the generator: a readonly [Key] field is written only under AllowPrivate (MsgPack007 / v3);
  ReflectionUnionFormatter populates the existing case instance; a type-level [MessagePackFormatter] inherited from a
  base class no longer claims a derived [MessagePackObject] type; GenericFormatterFactory's collection catch-all leaves
  [MessagePackObject] / [DataContract] / type-level-formatter types to the object tiers; an explicit interface
  implementation is skipped in the attributed table (contractless keeps v3's enumeration)
- a member [MessagePackFormatter(typeof(F<,>))] whose formatter lacks `allows ref struct` (netstandard-compiled, or
  hand-written without it) is served as a Compatible-only factory, so the graph reroutes to the Compatible buffers as for
  a netstandard-built factory instead of MakeGenericType's ArgumentException
- generator skips its ModuleInitializerAttribute polyfill when PolySharp is referenced (its CompilerVisibleProperty keys
  are present) and PolySharp still includes that attribute; README documents it and the PolySharpExcludeGeneratedTypes
  escape
- SignalR: RequiresDynamicCode message and README say DefaultAot writes enums as integers (compose
  EnumAsStringFormatterFactory<TEnum>) and has no contractless tier
- tests: AotLookupHarvestTests (+ Native AOT suite), ReflectionTierParityTests, PolySharpDetectionTests

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- generator inputs that threw inside the generator (CS8785, every generated file of the compilation lost) or failed
  only inside generated files now get a diagnostic at the declaration: an undefined KeyNamingPolicy value
  (MsgPack025), a [MessagePackObject] ref struct (MsgPack005), a keyed member under [Obsolete(error: true)]
  (MsgPack026, suggests [IgnoreMember]), a private/protected [UnionTag] case type (MsgPack006), a partial formatter or
  factory nested in a non-partial type (MsgPack027 from the companion generators, instead of CS0260)
- [MessagePackObject] on two partial declarations of one type (CS0579) emits the formatter once instead of hitting
  AddSource twice
- Escape writes U+0085 / U+2028 / U+2029 and other control characters as \uXXXX, so a string key with one no longer
  turns the rest of its comment into code
- the Key code fix annotates a positional record's parameters ([property: Key(n)], numbered before the body)
- docs: partial is needed only for AllowPrivate, serializable roots and partial formatters (Native AOT / IL2CPP do not
  need it; Unity section corrected); members from other source generators are invisible to this one; a user type named
  like a BCL/library type the generated code uses shadows it (rename); Roslyn 4.3 floor for every toolchain; compose
  SourceGeneratedFormatterFactory.Instance rather than the per-assembly internal GeneratedMessagePackFormatterFactory
  (CS0436 across InternalsVisibleTo), also in the generated registration comment
- tests: GeneratorRobustnessTests, CodeFixTests record case

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- every public entry that takes MessagePackSerializerOptions checks it (ArgumentNullException, as Serialize<T> did);
  the options and resolver constructors, Combine and AllowedTypes check their arguments too. README: options are
  required, v3 read null as DefaultOptions
- MsgPack108 judges the payload type argument: the Type-based buffer entries (Serialize<TWriteBuffer>(Type, ...)) are
  no longer reported for their buffer struct, and Serialize<TWriteBuffer, T> / Deserialize<TReadBuffer, T> are judged
- MsgPack101/108/110/111 see an inherited [MessagePackObject] (FormatterSymbols.FindInheritedMessagePackObject): an
  unannotated derived type of an annotated base is served by the Default chain's reflection tier, so its members and
  [Key]s are not reported as dead, and MsgPack111 sizes its keys
- struct collections with a collection-accepting constructor are served by the analyzer registry and harvested by the
  generator (the Add-based formatters stay class-only, as the runtime catch-all does)
- analyzer cost: the serializable-member registry is built lazily after the cheap attribute / method checks instead of
  on every callback; the entry-call analyzer compares the type name before ToDisplayString
- MsgPack115 also reports MessagePackPrimitives.TryReadArrayHeader / TryReadMapHeader in a body with a DeserializeState;
  MsgPack113 treats passing the buffer and the state by ref to a helper as a descent
- a partial formatter that constrains its own type parameters gets MsgPack028 with the buffer where-clauses to add
  (partial declarations that both carry constraints must match, so nothing can be generated); one that already
  constrains its buffer parameters stays silent. README explains the rule
- the not-found hint spells the type in C# (List<Order> instead of List`1) and shows the typeof attribute form, which
  every target has, next to the net9.0+ generic form; the non-generic entry message likewise
- README: factory example for every target (generic override on net9.0+, the bridged Type-based overload), typeof form
  in the AOT roots example, XML docs claim corrected; XML docs on the two CreateFormatter members say which to write
- tests: AnalyzerFindingsTests

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- AddMessagePackProtocol() registers the hub protocol through an explicit factory that picks the IOptions constructor,
  so an application that also registers MessagePackSerializerOptions as a service no longer gets an ambiguous-constructor
  InvalidOperationException from the container (TryAddEnumerable still sees the implementation type)
- UnityFormatterFactory writes its Type-based CreateFormatter overload itself (the Compatible-pair dispatch the companion
  generator would emit), so the Unity package compiles where the generator does not run (CS0534 before), and serves
  T?[], List<T?> and the WrapMode / GradientMode enums (with their wrapper forms) as roots on DefaultAot.WithUnity(),
  as v3's UnityResolver did; the class doc no longer credits the generic and enum tiers for them
- MsgPack113's helper rule (E) inspects the helper's body one level down: only a helper that forwards the state to a
  Serialize/Deserialize is a descent, so the Unity formatters' scalar readers (ReadVector3(ref buffer, ref state)) no
  longer trip it
- README: UPM git URL (path src/MessagePack.Unity, tag v4.0.0-preview.1), `using MessagePack.Unity;`, remove v3's
  com.github.messagepack-csharp first (same asmdef name, and its DefaultOptions auto-registration has no v4 equivalent);
  v3's opt-in UnityBlitResolver ext 30-39 forms have no v4 reader (migration row, compatibility sentence, not-in-preview
  list); a v3-built library that declares MessagePack types needs an explicit MessagePack.Annotations 4.x reference
  (3.x drops out of the unified graph and its types fail to load at run time); the shim README no longer says such
  assemblies "still load"
- tests: HubProtocolRegistrationTests, UnityAotRootsTests

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…docs

- Directory.Build.props sets ContinuousIntegrationBuild under GITHUB_ACTIONS, so the release build's PDBs and snupkg
  carry mapped source paths (DeterministicSourcePaths) instead of the runner's /home/runner/work/...
- the async boundary scanner resumes its multi-segment walk at a SequencePosition instead of re-slicing the sequence
  by offset on every read (a walk over every segment from the start: quadratic for one large message buffered in many
  small segments); the completed-reader drain loops slice from the tail rather than the buffer start
- ObjectFallbackFormatter and TypelessFormatter look their dispatch tables up by the value's own runtime type and run
  RuntimeTypeView.Normalize (IsVisible, a base-type walk) only on the miss; Typeless no longer normalizes before its
  primitive switch
- README: deserialized dictionaries and sets keep the flooding-resistant comparer (lookup cost, netstandard strings),
  an instance on the default comparer is replaced rather than refilled when populating; StringInterningFormatterFactory
  differs from v3's weak process-wide pool (strong per-set references, a lock per read)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
neuecc and others added 24 commits December 3, 2026 19:34
…only in case each keep their file

Hint names are compared without regard to case. The per-type formatter files and the enum name
formatters already told such twins apart; three other places did not:

- the generated half of a [MessagePackSerializable<T>] class (Client.DTO.Roots next to
  Client.Dto.Roots): CS8785 for MessagePackGenerator, so no generated file at all
- the Type-based CreateFormatter of a hand-written partial factory: CS8785 for FactoryBridgeGenerator
- the buffer constraints of a hand-written partial formatter: CS8785 for BufferConstraintsGenerator
  (its catch around AddSource does not see a duplicate from another output step)

The twin detection moves to HintNames and all five places use it. An ordinary compilation keeps its
plain hint names.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…entMode?> are roots on the AOT chain

v3's UnityResolver listed the nullable enum arrays and lists next to the plain ones. The factory's
enum helper stopped at T, T?, T[] and List<T>, so under DefaultAot.WithUnity() (IL2CPP, Native AOT),
which has no generic tier to close them, these four were "Type ... is not found". The helper now
closes the same six forms as the value-type helper.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
… to declare it

Under DefaultAot (Native AOT, IL2CPP) a closed generic [MessagePackObject] type is served only where the
generator of the assembly that declares the definition constructed it: the generated formatter is internal
to that assembly. The missing-formatter message recommended [MessagePackSerializable] for every generic
miss, which for Envelope<OrderLine> with the envelope in a library is the declaration MsgPack022 reports
as registering nothing. The message now adds where the declaration has to be, and what to do when the
type argument is not visible there (a non-generic class derived from the closed type).

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…he v4 README draft and the migration guide

ReadMe.v4.md:
- Native AOT: a generic [MessagePackObject] type is prepared only by the assembly that declares it, with
  the two ways round it (declare the instantiation there; derive a class where the type argument lives)
- Message and element streams: what a failed message leaves behind, and when a new enumeration can go on
- Populating: a call that throws leaves the instance partly overwritten; a shared instance behind a
  member initializer is overwritten for every object
- Typeless: types without [MessagePackObject] are read with their private members, as in v3, and how to
  leave those out
- Unity: the nullable, array and list forms and the two enums need no root declaration under DefaultAot

doc/migrating_v3-v4.md: the two places where v3 did more (its generator created the formatter of another
assembly's generic type in the using project; UntrustedData refused a key type it could not protect).

The test pins the stream sentence for a seekable Stream.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…ed list

The sample for TypelessTypeLoader.Create translated the old name and then resolved it by name. It now
asks an AllowedTypes loader, which is what the section recommends everywhere else.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
… name accepts

The same note the README gives next to its sample, on the method itself: such a delegate is for trusted
data, and a renamed type is read by translating the name and asking an AllowedTypes loader.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The RE:Dox charts and the simdjson charts of the v4 README draft are
in microseconds now. Throughput in GB of JSON per second credited the
MessagePack rows with bytes they never wrote or read; across formats
only time is what was measured.

The RE:Dox charts draw the five documents between 100 KB and 500 KB as
MessagePack (citm_catalog, mesh, random, twitter, update-center), whose
times share one axis, with every bar labeled; the tables keep all
twelve documents and the geometric mean. The simdjson section says what
simdjson reports (18.9 and 5.9 GB/s of JSON on this machine) and the
times those are. A bar of System.Text.Json that passes the axis is cut
and says its value.

The charts are designed at 838 px, the width of a README image on
GitHub, and exported at twice that. The introduction is shorter: the
paragraph on v3 and the sentence under the chart are gone.

doc/MessagePack-benchmark.xlsx holds the same measurements; its chart
sheets and the five PNGs are rebuilt.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…eled as C++

The introduction is one sentence on what v4 is and three principles of
a sentence or two each. The third is "Version-tolerant by explicit
declaration": the C# types are the schema, and explicit annotations are
what makes schema evolution safe. "Secure by default" says that the
default configuration is the one for untrusted data.

Installation shows the one package to install and lists the others as
optional additions, each linked to its section. That v3 and v4 read
each other's data is said under the migration notes.

In the simdjson charts, the table and the workbook, the row is
"simdjson (C++)": it is the one row that is not a .NET library.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…oxConsoleApp

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… are required

ConvertToJson leaves the Quick Start: it is a diagnostic method and is
introduced where Object Serialization first prints with it. In its
place the Quick Start says that the C# types are the schema, as a
.proto file or a JSON Schema is one, which is why [MessagePackObject]
is required on every type of the graph, that an analyzer and a code fix
cover a missing annotation, and that a key is an int (array) or a
string (map).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ty options" in the v4 README draft

The three ways of serializing that work through reflection instead of
the source generator are one section near the end, introduced as not
recommended in v4 but still available, and not available on Native
AOT. The main flow no longer passes through them: Private members says
that private members are not serialized by default, Dynamic (Untyped)
Deserialization follows Object Type Serialization and its sample no
longer builds its data with the contractless options, and Native AOT
moves up, ahead of Security.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… in the v4 README draft

The serialization constructor, records, init and required members,
callbacks, circular references and enums as names are subsections of
Object Serialization, next to private members.

Enums as names shows EnumAsStringFormatterFactory<T> both ways: on the
enum, where it reaches every use of the enum, and on one member. On a
member the attribute serves the enum type itself; on a List<Status>
member the factory has no formatter to offer and serializing throws,
so the text says so.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The section no longer offers Deserialize<dynamic>, which does not run
on Native AOT. It describes Deserialize<object> and shows
Dictionary<string, object> as the target for a map with string keys:
an array comes back as object[], an integer in the width it was written
with, a nested map as Dictionary<object, object>. With DefaultAot,
Deserialize<object> works as it is and Dictionary<string, object> is
declared as a root.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e AOT takes

The calls of the Quick Start use MessagePackSerializerOptions.Default,
the options meant for JIT, and building for Native AOT warns about
them; there the same two calls take DefaultAot. The paragraph points to
the Native AOT section for the rest.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…OT works "as it is"

The Quick Start now says that Native AOT takes DefaultAot explicitly.
The principle says what does carry over unchanged: the formatters
generated at compile time.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ays what malformed data does

The opening is one paragraph: where untrusted data comes from, that the
default configuration is the one meant for it, and that data which
cannot be deserialized throws MessagePackSerializationException. The
sentence on authenticating data with a MAC is gone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…th their point

Performance starts with what the section is about: a serializer's speed
depends on the kind of data, v4 is tuned for every kind, and array is
the default because the default is what gets used. The POCO paragraph
keeps only the description of its benchmark.

Compression ends with a recommendation: it gains most where string keys
repeat, so int keys, which do not repeat names at all, come first.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ngs are removed

The closing sentences of Performance said what its opening now says.
The hint "Choosing compression" said what the Compression section now
ends with; its one sentence that was nowhere else, to measure the
effect because compression costs time, moves there.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…reate the options once"

The options are a light record around the resolver, and deriving
options from existing ones (a with expression, or new options over the
same resolver) is an intended use. What must not be created per call is
a resolver, which is what the two constructors that take a factory do.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ssagePackPrimitives

The section had only MessagePackWriter and MessagePackReader. It now
has three parts. MessagePackPrimitives comes first and is the
recommended level: the TryWrite, TryRead and UnsafeWrite families over
spans, what a DecodeResult says, and the same tokens as extension
methods on the buffers of SerializerFoundation, with a sample that
creates a buffer outside a formatter and passes one value through
MessagePackSerializer. MessagePackWriter and MessagePackReader follow
as the simpler way, each with its half of the former sample.

The Low-Level API section points at the new headings.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… with use cases

Under the chart, one line sends the reader to the Performance section.
A "Use cases" section before the .NET Foundation notice describes
MagicOnion, as the v3 README did, and MasterMemory, which stores its
database as MessagePack.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ReadMe.v4.md replaces the release-candidate README, which was a
migration walkthrough followed by the new features. The migration
material lives in doc/migrating_v3-v4.md; the README is now the
reference for v4 itself.

The link from the migration guide to the README's custom formatter
example points at the Low-Level API section, and the headers of the
four benchmarks that name the file the numbers are in say README.md.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
master holds MessagePack for C# v3 up to 3.1.12. v4 is a rebuild and
takes nothing from it: this merge records master as an ancestor, with
the ours strategy, so that v4 can be merged into master without
conflicts. The tree is the one of the previous commit, unchanged.

v3 continues on the v3.x branch, cut from master at c633b45.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The repository moved from the MessagePack-CSharp organization to
Cysharp. The package metadata (PackageProjectUrl, and RepositoryUrl
with it), the README's release badge, its five chart images and the
Unity git URL, the Unity URL of the migration guide and the link of
SECURITY.md name the new location.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@neuecc neuecc changed the title MessagePack for C# v4.0.0-rc.1 MessagePack for C# v4.0.0 Dec 4, 2026
@neuecc
neuecc marked this pull request as ready for review December 4, 2026 09:03
neuecc and others added 2 commits December 4, 2026 18:04
The release workflow sets this version from the tag and pushes the
change to the branch it runs on. With the version already in place it
has nothing to commit, so releasing v4.0.0 from master needs no push
past the branch's ruleset.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The sentence about 3.0 being serviced until 3.1 is stable described a
moment that passed with 3.1. The policy now says where the versions
live: 4.x on master, 3.x and 2.x for security fixes only on the v3.x
and v2.x branches. The table of supported versions is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@neuecc
neuecc merged commit b95b360 into master Dec 4, 2026
8 checks passed
@neuecc
neuecc deleted the v4 branch December 4, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants