Bodu.Text.Toml 0.7.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bodu.Text.Toml --version 0.7.0
                    
NuGet\Install-Package Bodu.Text.Toml -Version 0.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bodu.Text.Toml" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bodu.Text.Toml" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="Bodu.Text.Toml" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bodu.Text.Toml --version 0.7.0
                    
#r "nuget: Bodu.Text.Toml, 0.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bodu.Text.Toml@0.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bodu.Text.Toml&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=Bodu.Text.Toml&version=0.7.0
                    
Install as a Cake Tool

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, and DateTimeOffset/DateTime/DateOnly/TimeOnly → the four RFC 3339 date-time forms; byte[] → an integer array (or a Base64 string via TomlSerializerOptions.ByteArrayHandling); enums → member-name strings. decimal and TimeSpan have no native TOML form and require a registered TomlConverter<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), the ITomlOn* serialization callbacks, naming policies and TomlSerializerDefaults.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) and TomlSerializationException (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 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.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.

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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 85 9/24/2026
0.7.0 154 9/24/2026
0.6.0 90 9/24/2026
0.5.0 79 9/23/2026