feat(storage): add System.Text.Json grain storage serializer
Problem
Orleans grain storage uses Newtonsoft.Json by default. Applications which prefer System.Text.Json need an integrated storage serializer, including support for Orleans runtime types commonly found in persisted state.
Solution
Add SystemTextJsonGrainStorageSerializer and the opt-in UseSystemTextJsonGrainStorageSerializer() silo-builder extension.
The serializer supports Orleans activation, grain, silo, membership, stream, subscription, endpoint, and grain-reference types. It establishes compact canonical formats for new persisted state: scalar values use strings or numbers, fixed-arity composite values use arrays, and optional subscription state uses a camelCase object. Stream dictionary keys use length-prefixed components to preserve arbitrary namespaces, keys, and provider names without delimiter ambiguity.
Converters validate token shapes, required components, UTF-8 content, and supported runtime types. System.Text.Json treats legacy $type metadata as ordinary data, while converter discriminators select only fixed Orleans types.
Rationale
System.Text.Json provides a modern, lower-allocation serialization option with explicit canonical storage contracts. Keeping runtime identity strings separate from JSON formats preserves Orleans routing and pub/sub identities while allowing storage formats to remain compact and unambiguous.
Enable it with:
builder.UseSystemTextJsonGrainStorageSerializer();
Applications can customize the underlying JsonSerializerOptions through SystemTextJsonGrainStorageSerializerOptions.