Descent.RngKit.Serialization
0.1.0
dotnet add package Descent.RngKit.Serialization --version 0.1.0
NuGet\Install-Package Descent.RngKit.Serialization -Version 0.1.0
<PackageReference Include="Descent.RngKit.Serialization" Version="0.1.0" />
<PackageVersion Include="Descent.RngKit.Serialization" Version="0.1.0" />
<PackageReference Include="Descent.RngKit.Serialization" />
paket add Descent.RngKit.Serialization --version 0.1.0
#r "nuget: Descent.RngKit.Serialization, 0.1.0"
#:package Descent.RngKit.Serialization@0.1.0
#addin nuget:?package=Descent.RngKit.Serialization&version=0.1.0
#tool nuget:?package=Descent.RngKit.Serialization&version=0.1.0
Descent.RngKit.Serialization
Opt-in System.Text.Json serialization for Descent.RngKit —
a zero-allocation, never-throw dice expression engine for high-concurrency virtual tabletops.
This package contains one type: RngKitJsonContext, the source-generated JsonSerializerContext for
RngAuditPacket and the contracts it carries. It depends on Descent.RngKit.Abstractions and nothing
depends on it.
dotnet add package Descent.RngKit.Serialization --version 0.1.0
Pre-1.0. Below
1.0.0the public API is unstable by declaration — SemVer permits breaking changes in any0.xminor release — so pin an exact version rather than a floating range.
Usage
using System.Text.Json;
using Descent.RngKit.Serialization;
string json = JsonSerializer.Serialize(packet, RngKitJsonContext.Default.RngAuditPacket);
var packet = JsonSerializer.Deserialize(json, RngKitJsonContext.Default.RngAuditPacket);
Source-generated rather than reflection-based, so it is Native AOT and trim safe: no IL2026/IL3050
warnings and no runtime code generation. Polymorphic IRngMetadata payloads round-trip through the
[JsonPolymorphic] / [JsonDerivedType] discriminators declared on the interface in
Descent.RngKit.Abstractions.
Why this is a separate package
Descent.RngKit.Abstractions describes what a roll result is. It takes no position on how you put
it on a wire, so a host using MessagePack, protobuf, or any other format does not carry a JSON
serializer in its contract layer.
Splitting it out took Descent.RngKit.Abstractions.dll from 261,632 to 100,864 bytes (−61.5%),
both measured on the x64 Release build.
That is worth having for NuGet download size, for framework-dependent deployments, and for hosts that
map contract assemblies into per-plugin AssemblyLoadContext sandboxes, where each loaded assembly
costs metadata.
It does not shrink a Native AOT image, and it was never going to. ILCompiler already strips an
unreferenced JsonSerializerContext — it is an ordinary class, and nothing about [JsonSerializable]
roots it. A non-serializing consumer measured byte-identical before and after the split: 3,880,448
bytes either way. The general point, since it is easy to get wrong: under Native AOT the unit of
dead-code elimination is reachability, not assembly, so splitting a package is not a trimming
strategy. The control experiment is recorded in
§3.1a of the multi-angle review.
Links
- 📦
Descent.RngKit.Abstractions— the contracts - 📦
Descent.RngKit— the engine - 📦
Descent.RngKit.Mechanics— the standard ruleset library - 📘 Syntax reference
MIT © DescentVTT Team
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Descent.RngKit.Abstractions (>= 0.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|