Table of Contents

TomlWriterOptions Struct

Definition

Namespace
Bodu.Text.Toml.Writer
Assembly
Bodu.Text.Toml.dll
Package
Bodu.Text.Toml 1.0.0
Source
TomlWriterOptions.cs

Defines the customizations applied when creating a Utf8TomlWriter.

public struct TomlWriterOptions
Inherited Members
Extension Methods

Remarks

TOML output always uses a normalized layout - keys are emitted in insertion order, sub-tables surface as [header] blocks, arrays of tables as [[header]] blocks, and every value uses its shortest round-trippable spelling - so there is no indentation or encoder option. The layout is deterministic for a given insertion order, but two semantically equal documents built in different orders serialize to different bytes; it is not a canonical form suitable for hashing or signing.

The writer always emits text that is valid under both TOML v1.0.0 and v1.1.0, so SpecVersion has no effect on output today; MaxDepth bounds container nesting, guarding against stack-exhausting graphs. A value of 0 selects the default of 64, and a larger value is clamped to the hard ceiling Bodu.Text.Toml.TomlLimits.AbsoluteMaxDepth; opening a table or array deeper than the effective limit throws TomlSerializationException rather than risking a StackOverflowException.

var buffer = new ArrayBufferWriter<byte>();
var writer = new Utf8TomlWriter(buffer, new TomlWriterOptions
{
    SpecVersion = TomlSpecVersion.V1_1,   // permit 1.1-only constructs on write
    MaxDepth = 16,
});

Properties

MaxDepth

Gets or sets the maximum container nesting depth the writer will permit.

public int MaxDepth { readonly get; set; }

Property Value

int

The maximum container nesting depth; 0 selects the default of 64, clamped to Bodu.Text.Toml.TomlLimits.AbsoluteMaxDepth.

SpecVersion

Gets or sets the version of the TOML specification associated with the writer.

[Obsolete("The writer emits output valid under both TOML v1.0.0 and v1.1.0, so SpecVersion has no effect; it will be removed in a future release.")]
public TomlSpecVersion SpecVersion { readonly get; set; }

Property Value

TomlSpecVersion

The target specification version; the default is V1_0.

Remarks

The property has no effect: the writer emits normalized output that is valid under both TOML v1.0.0 and v1.1.0 regardless of the value. It is obsolete and will be removed in a future release.

Applies to

ProductVersions
.NET8, 10