Bodu.Text.Serialization
1.3.0
dotnet add package Bodu.Text.Serialization --version 1.3.0
NuGet\Install-Package Bodu.Text.Serialization -Version 1.3.0
<PackageReference Include="Bodu.Text.Serialization" Version="1.3.0" />
<PackageVersion Include="Bodu.Text.Serialization" Version="1.3.0" />
<PackageReference Include="Bodu.Text.Serialization" />
paket add Bodu.Text.Serialization --version 1.3.0
#r "nuget: Bodu.Text.Serialization, 1.3.0"
#:package Bodu.Text.Serialization@1.3.0
#addin nuget:?package=Bodu.Text.Serialization&version=1.3.0
#tool nuget:?package=Bodu.Text.Serialization&version=1.3.0
Bodu.Text.Serialization
API stability - Stable. The public API surface is committed: breaking changes are reserved for a major-version bump per SemVer, except a deliberate break that is recorded in the release notes and in the package's
CompatibilitySuppressions.xml. See versioning and support.
The shared serialization core for the Bodu System.Text.Json-shaped text serializers (Bencode, TOML, YAML, Delimited, DotEnv, INI). It carries the format-agnostic pieces those libraries have in common: the declarative attribute family, the shaping enums, the serialization callback interfaces, and the property naming policies - all in the single Bodu.Text.Serialization namespace, so one [PropertyName] or NamingPolicy.CamelCase works identically across every format.
Installation
dotnet add package Bodu.Text.Serialization
Targets net8.0 and net10.0. You rarely install this package directly - each per-format serializer package references it, so it arrives transitively with Bodu.Text.Toml, Bodu.Text.Yaml, and their siblings. Reference it directly only when a model assembly should carry the mapping attributes without depending on any specific format.
API shape
| Type(s) | Role |
|---|---|
[PropertyName] / [Ignore] / [Converter] / [PropertyOrder] / [Required] / [Include] / [ExtensionData] / [Constructor] / [ObjectCreationHandling] / [NamingPolicy] / [UnmappedMemberHandling] / [StringEnumMemberName] |
The declarative member-shaping attribute family, rooted at SerializationAttribute. Applied once on a model, honored by every Bodu text serializer. |
IgnoreCondition, ObjectCreationHandling, UnmappedMemberHandling, KnownNamingPolicy |
The shaping enums the attributes and per-format options share (conditional omission, replace-vs-populate on read, unknown-key policy, attribute-addressable naming policies). |
IOnSerializing / IOnSerialized / IOnDeserializing / IOnDeserialized |
Serialization lifecycle callbacks a model opts into by implementing the interface. |
NamingPolicy (with CamelCase, SnakeCaseLower / SnakeCaseUpper, KebabCaseLower / KebabCaseUpper) |
Property naming policies converting CLR member names to wire keys. |
using Bodu.Text.Serialization;
public sealed class Profile
{
[PropertyName("display-name")]
public string DisplayName { get; set; } = "Ada";
[Ignore(Condition = IgnoreCondition.WhenWritingNull)]
public string? Comment { get; set; }
}
// The same model serializes consistently through any sibling:
// TomlSerializer.Serialize(profile) -> display-name = "Ada"
// YamlSerializer.Serialize(profile) -> display-name: Ada
Shared engine source
Beyond the compiled assembly, the package's repository folder also hosts the shared/** engine source - the metadata resolver (MetadataResolver / TypeMetadata / PropertyMetadata), the structural converter factories (nullable / dictionary / collection / object), and the converter pipeline - which the per-format packages compile into themselves under their format symbol (BENCODE, TOML, YAML, …). That source is a repository-level implementation detail: it ships inside each format assembly, not in this package, so this package stays a small attribute/contract library whose only dependency is Bodu.Core.
The line formats (Delimited, DotEnv, INI) wire every value as a string, so they share a smaller body of source instead, kept apart from shared/** in flat/src/: the member discovery and descriptors, the scalar classification and invariant scalar text (InvariantScalarCodec), the binder helpers DotEnv and INI share, the UTF-8 line cursor the three readers scan line endings and the byte-order mark with, and the output sink the three writers write through. Each line format compiles every file in it; the tests for it live once in flat/test/, compiled into each line format's test project.
Building and testing
To build this package from source and run its tests, see CONTRIBUTING.md.
License
MIT. © Bodu Pty. Ltd.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Bodu.Text.Serialization:
| Package | Downloads |
|---|---|
|
Bodu.Text.Toml
A self-contained TOML (v1.0.0 / v1.1.0) library for .NET 8 and .NET 10, shaped after System.Text.Json and matching the sibling Bodu.Text.Bencode surface: the TomlSerializer POCO mapper (converters, the full attribute family, naming policies, callbacks), the forward-only ref-struct Utf8TomlReader/Utf8TomlWriter token surface, a mutable TomlNode DOM, and a read-only TomlDocument DOM. Adds native float, boolean, and the four RFC 3339 date-time kinds. |
|
|
Bodu.Text.Delimited
A self-contained delimited-text (RFC 4180 CSV/TSV) library for .NET 8 and .NET 10, shaped after System.Text.Json and matching the sibling Bodu.Text.Toml surface: the forward-only ref-struct Utf8DelimitedReader/Utf8DelimitedWriter token surface over UTF-8, a mutable DelimitedNode DOM, a read-only DelimitedDocument DOM, and the DelimitedSerializer record mapper with an IAsyncEnumerable streaming surface. A delimited document is an array of records. |
|
|
Bodu.Text.DotEnv
A self-contained DotEnv library for .NET 8 and .NET 10, shaped after System.Text.Json and matching the sibling Bodu.Text.Toml surface: the forward-only ref-struct Utf8DotEnvReader/Utf8DotEnvWriter token surface over UTF-8, a mutable DotEnvNode DOM, a read-only DotEnvDocument DOM, and the DotEnvSerializer POCO mapper. DotEnv models a flat, ordered object of string-valued keys with export prefixes and comment trivia. |
|
|
Bodu.Text.Ini
A self-contained INI library for .NET 8 and .NET 10, shaped after System.Text.Json and matching the sibling Bodu.Text.Toml surface: the forward-only ref-struct Utf8IniReader/Utf8IniWriter token surface over UTF-8, a mutable IniNode DOM, a read-only IniDocument DOM, and the IniSerializer POCO mapper. INI models a two-level object-of-objects (sections then string keys). |
|
|
Bodu.Text.Bencode
A self-contained Bencode (BEP 3) library for .NET 8 and .NET 10, shaped after System.Text.Json: the BencodeSerializer POCO mapper (converters, the full attribute family, naming policies, callbacks), the forward-only ref-struct Utf8BencodeReader/Utf8BencodeWriter token surface, a mutable BencodeNode DOM, and a read-only BencodeDocument DOM. Reads and writes canonical BEP 3 (ascending unique dictionary keys, single root) and can return a value's exact encoded slice for info-hash scenarios. |
GitHub repositories
This package is not used by any popular GitHub repositories.