Tomlyn v1 targets TOML 1.1.0 only. It does not support TOML 1.0 or earlier drafts.
See the official TOML v1.1.0 specification for the full language reference.
| Framework | Notes |
|---|---|
net10.0 |
Fully optimized, all features available. |
net8.0 |
Fully optimized, all features available. |
netstandard2.0 |
Broad runtime compatibility; some newer numeric types (Half, Int128) unavailable. |
Tomlyn supports two metadata paths for object mapping:
| Path | Description | Trimming/AOT safe |
|---|---|---|
| Source generation | TomlSerializerContext / TomlTypeInfo<T> |
✅ Yes |
| Reflection | Automatic at runtime (enabled by default) | ⚠️ Requires annotations |
Reflection-based object mapping can be disabled before first use:
AppContext.SetSwitch("Tomlyn.TomlSerializer.IsReflectionEnabledByDefault", false);
This switch must be set before the first call to TomlSerializer. Setting it after will have no effect.
When reflection is disabled:
TomlTypeInfo<T> or TomlSerializerOptions.TypeInfoResolver.TomlTable, TomlArray) remain supported without reflection.See Source generation and NativeAOT for details.
Tomlyn reuses System.Text.Json types in two areas:
TomlSerializerOptions.PropertyNamingPolicy accepts any JsonNamingPolicy.System.Text.Json.Serialization attributes work out of the box.[JsonSerializable] roots and JsonKnownNamingPolicy are used for context declaration.This allows you to share model classes between JSON and TOML serializers. TOML-specific attributes take precedence when both are present.