Bodu.Text.Toml
1.0.0
dotnet add package Bodu.Text.Toml --version 1.0.0
NuGet\Install-Package Bodu.Text.Toml -Version 1.0.0
<PackageReference Include="Bodu.Text.Toml" Version="1.0.0" />
<PackageVersion Include="Bodu.Text.Toml" Version="1.0.0" />
<PackageReference Include="Bodu.Text.Toml" />
paket add Bodu.Text.Toml --version 1.0.0
#r "nuget: Bodu.Text.Toml, 1.0.0"
#:package Bodu.Text.Toml@1.0.0
#addin nuget:?package=Bodu.Text.Toml&version=1.0.0
#tool nuget:?package=Bodu.Text.Toml&version=1.0.0
Bodu.Text.Toml
API stability — Stable. The public API surface is committed; breaking changes are reserved for a major-version bump per SemVer.
A TOML (v1.0.0 / v1.1.0) library for .NET 8. It maps plain CLR objects to and from TOML through a configurable converter model, over a low-level forward-only token reader and writer, with both a mutable and a read-only document object model.
Installation
dotnet add package Bodu.Text.Toml
Targets net8.0.
API shape
The public surface matches the sibling Bodu.Text.Bencode library, so the patterns transfer directly between the two. The types are organised into folders/namespaces by surface:
| Type(s) | Namespace | Role |
|---|---|---|
TomlSerializer / TomlSerializerOptions / TomlSerializerDefaults |
Bodu.Text.Toml |
Static serializer entry point, its configuration, and scenario presets (for example Web). |
TomlNamingPolicy, TomlTokenType, TomlValueKind |
Bodu.Text.Toml |
Property naming policies, token classification, and value-kind classification. |
TomlFormatException / TomlSerializationException |
Bodu.Text.Toml |
Failures split by cause: malformed input vs. values that cannot be mapped. |
Utf8TomlReader (+ TomlReaderOptions) |
Bodu.Text.Toml.Reader |
Forward-only, allocation-free ref struct token reader. |
Utf8TomlWriter (+ TomlWriterOptions) |
Bodu.Text.Toml.Writer |
Forward-only ref struct token writer. |
TomlDocument / TomlElement / TomlProperty |
Bodu.Text.Toml.Document |
Read-only, low-allocation document object model. |
TomlNode / TomlObject / TomlArray / TomlValue |
Bodu.Text.Toml.Nodes |
Mutable document object model: parse, edit, write back. |
TomlConverter<T> / TomlConverterFactory, [TomlPropertyName] / [TomlIgnore] / … |
Bodu.Text.Toml.Serialization |
Custom converters and the per-member attribute family. |
using Bodu.Text.Toml;
string toml = TomlSerializer.Serialize(new ServerConfig { Host = "localhost", Port = 8080 });
ServerConfig config = TomlSerializer.Deserialize<ServerConfig>(toml);
// Document object models
using Bodu.Text.Toml.Nodes;
TomlNode node = TomlNode.Parse(utf8Toml)!;
node["server"]!["port"] = 9090;
byte[] back = node.ToUtf8Bytes();
- Value mapping:
string/char/Guid/Uri→ string, the integer family → integer,double/float→ float,bool→ boolean, andDateTimeOffset/DateTime/DateOnly/TimeOnly→ the four RFC 3339 date-time forms;byte[]→ an integer array (or a Base64 string viaTomlSerializerOptions.ByteArrayHandling); enums → member-name strings.decimalandTimeSpanhave no native TOML form and require a registeredTomlConverter<T>. - A TOML document root must map to a table, so a top-level scalar or array throws. Output is normalized TOML in document order — deterministic for a given input, with member order preserved (so
[TomlPropertyOrder]is honored). It is not a canonical form: two equal documents built in different member orders serialize differently, so the output is unsuitable for hashing or signing. - The full serializer feature surface is present: converters and factories, the attribute family (
TomlPropertyName/Ignore/Converter/PropertyOrder/Constructor/Required/Include/ExtensionData/NamingPolicy/UnmappedMemberHandling/ObjectCreationHandling/StringEnumMemberName), theITomlOn*serialization callbacks, naming policies andTomlSerializerDefaults.Web, and the string/number enum converters. - Because the reader/writer/document types live in sub-namespaces, code that uses them alongside the serializer imports
using Bodu.Text.Toml.Reader;/.Writer;/.Document;/.Nodes;as needed. - Failures surface through
TomlFormatException(malformed input, with line/column/offset) andTomlSerializationException(binding failures).
Runnable samples
The repository ships offline, dotnet run-able sample projects for this package — the
TomlSerializer POCO surface (temporal kinds, naming policies and attributes, the wire
knobs) and the layers beneath it (both DOMs, the token reader/writer, streaming reads) —
under samples/Text.Toml/.
Testing
Tests live in test/ as MSTest classes mirroring src/. Run tiers via the runsettings files at the solution root:
dotnet test Bodu.Text.Toml/test/Bodu.Text.Toml.Test.csproj --settings bvt.runsettings
dotnet test Bodu.Text.Toml/test/Bodu.Text.Toml.Test.csproj --settings regression.runsettings
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. |
-
net10.0
- Bodu.Core (>= 1.0.0)
- Bodu.Text.Serialization (>= 1.0.0)
-
net8.0
- Bodu.Core (>= 1.0.0)
- Bodu.Text.Serialization (>= 1.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Bodu.Text.Toml:
| Package | Downloads |
|---|---|
|
Bodu.Globalization.Calendar.Caching
Caching layer for Bodu.Globalization.Calendar. Provides CachingNotableDateService, a decorator that wraps any INotableDateService and serves computed notable dates from a per-territory, per-civil-year cache (in-memory or one TOML/JSON file per territory), recording when each year was computed and refreshing on a configurable time-to-live or a resource-version change. Includes the dependency-injection registration (AddCachedNotableDateService) on IServiceCollection. |
|
|
Bodu.Extensions.Configuration.Text
The EditorConfig-compatible Microsoft.Extensions.Configuration provider. Bridges Bodu.Text.Configuration into the standard IConfiguration / IOptions<T> pipeline so a .boduconfig or bodu.config file registers with the same AddTextConfiguration(...) shape used for the JSON, INI, and XML providers — with file, stream, and programmatic-document overloads, reload-on-change, and colon-delimited section binding. Also ships the read-only TOML (AddTomlFile / AddTomlStream) and Bencode (AddBencodeFile / AddBencodeStream) sources. |
|
|
Bodu.Financial.ExchangeRates.Caching
Caching layer for Bodu.Financial exchange-rate providers. Provides CachingRateProvider, a decorator that wraps any IDatedRateProvider and serves fresh rates from a shared on-disk cache (one TOML file per provider and currency pair), plus an AggregatingRateProvider (priority-fallback, averaging, per-pair routing). Includes the dependency-injection registrations (AddCachedRateProvider, AddAggregatedRateProvider) on IFinancialServiceBuilder. |
GitHub repositories
This package is not used by any popular GitHub repositories.