Skip to content
Shiny.NET

Serialization Release Notes

Fix
Primitives and common BCL value types (string, bool, numerics, Guid, DateTime, DateTimeOffset, TimeSpan, Uri, nullable forms, etc.) now serialize without a registered JsonSerializerContext. Previously Shiny.Json.Default.Serialize<string>(...) threw “No JsonTypeInfo registered for type ‘System.String’” unless some registered context happened to include string. Registered contexts still take precedence
Feature
New library Shiny.Extensions.Serialization. Centralizes every JsonSerializerContext in your app behind a single shared ISerializer so AOT/source-gen contexts compose via TypeInfoResolverChain instead of fragmenting across services
Feature
Shiny.Json static accessor — self-bootstrapping, sibling to Shiny.Stores. Shiny.Json.Default, AddContext, AddResolver, Configure, Reset, CreateTestScope. Works before DI exists (mobile cold-start path)
Feature
Source generator: [ShinyJsonContext] on a user-declared JsonSerializerContext partial emits a [ModuleInitializer] calling Shiny.Json.AddContext(MyContext.Default) before Main. Drops the services.AddJsonContext(...) boilerplate and fixes “I forgot to register in this code path” bugs
Feature
Source generator: [ShinyJsonInclude] on a type (or [assembly: ShinyJsonInclude(typeof(T))] for foreign types) emits an AOT-safe IJsonTypeInfoResolver providing JsonTypeInfo for List<T>, T[], IEnumerable<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IList<T>, ICollection<T>, and IAsyncEnumerable<T>. Element JsonTypeInfo is resolved lazily from the chain, so collection wrappers compose with any context that supplies the element
Feature
Inline [JsonConverter(typeof(MyConverter))] composes with the generated collection resolver: the converter handles the element (Foo → bare number, custom shape, etc.) and the generated wrapper handles the collection. Fixes the long-standing “single instance works under AOT, List<T> throws” trap
Feature
DI extensions: services.AddJsonSerialization(), AddJsonContext(JsonSerializerContext), ConfigureJsonSerializer(Action<JsonSerializerOptions>), AddSerializer(ISerializer), AddSerializer<TSerializer>(), IServiceProvider.UseSerializer()
Feature
Diagnostic SJSON002 (error) — [ShinyJsonInclude] on an unbound generic. Diagnostic SJSON003 (warning) — [ShinyJsonInclude] on a type with no [JsonSerializable(typeof(T))] declared anywhere in the compilation
Feature
UTF-8 byte and stream overloads on ISerializer: SerializeToUtf8Bytes, Deserialize(ReadOnlySpan<byte>), SerializeAsync(Stream, ...), DeserializeAsync<T>(Stream, ...) and their runtime-typed siblings