![]() |
VOOZH | about |
dotnet add package Tomlyn.Signed --version 2.7.0
NuGet\Install-Package Tomlyn.Signed -Version 2.7.0
<PackageReference Include="Tomlyn.Signed" Version="2.7.0" />
<PackageVersion Include="Tomlyn.Signed" Version="2.7.0" />Directory.Packages.props
<PackageReference Include="Tomlyn.Signed" />Project file
paket add Tomlyn.Signed --version 2.7.0
#r "nuget: Tomlyn.Signed, 2.7.0"
#:package Tomlyn.Signed@2.7.0
#addin nuget:?package=Tomlyn.Signed&version=2.7.0Install as a Cake Addin
#tool nuget:?package=Tomlyn.Signed&version=2.7.0Install as a Cake Tool
<img align="right" width="256px" height="256px" src="img/Tomlyn.png">
Tomlyn is a high-performance .NET TOML 1.1 parser, round-trippable syntax tree, and System.Text.Json-style object serializer - NativeAOT ready.
Note: Tomlyn v1 is a major redesign with breaking changes from earlier versions. It uses a
System.Text.Json-style API withTomlSerializer,TomlSerializerOptions, and resolver-based metadata (ITomlTypeInfoResolver). See the migration guide for details.
System.Text.Json-style API: familiar surface with TomlSerializer, TomlSerializerOptions, TomlTypeInfo<T>TomlSerializerContext and [TomlSerializable] rootsSystem.Text.Json attribute interop: reuse [JsonPropertyName], [JsonIgnore], [JsonRequired], [JsonConstructor], [JsonObjectCreationHandling], and polymorphism attributes[TomlSingleOrArray]TomlLexer → TomlParser with precise spans for errorsSyntaxParser → DocumentSyntax)Tomlyn targets net8.0, net10.0, and netstandard2.0.
netstandard2.0 (including .NET Framework) or modern .NET (net8.0+).dotnet add package Tomlyn
Tomlyn ships the source generator in-package (analyzers/dotnet/cs) - no extra package needed.
using Tomlyn;
// Serialize
var toml = TomlSerializer.Serialize(new { Name = "Ada", Age = 37 });
// Deserialize
var person = TomlSerializer.Deserialize<Person>(toml);
TomlTable)using Tomlyn;
using Tomlyn.Model;
var toml = @"global = ""this is a string""
# This is a comment of a table
[my_table]
key = 1 # Comment a key
value = true
list = [4, 5, 6]
";
var model = TomlSerializer.Deserialize<TomlTable>(toml)!;
var global = (string)model["global"]!;
Console.WriteLine(global);
Console.WriteLine(TomlSerializer.Serialize(model));
POCO properties can also use TomlObject when a member should accept any TOML model container (TomlTable, TomlArray, or TomlTableArray). This works with both reflection-based serialization and source-generated TomlSerializerContext metadata.
using System.Text.Json;
using Tomlyn;
var options = new TomlSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
PreferredObjectCreationHandling = JsonObjectCreationHandling.Replace,
WriteIndented = true,
IndentSize = 4,
MaxDepth = 64,
DefaultIgnoreCondition = TomlIgnoreCondition.WhenWritingNull,
};
var toml = TomlSerializer.Serialize(config, options);
var model = TomlSerializer.Deserialize<MyConfig>(toml, options);
By default, PropertyNamingPolicy is null, meaning CLR member names are used as-is for TOML mapping keys (same default as System.Text.Json).
MaxDepth = 0 uses the built-in default of 64.
PreferredObjectCreationHandling = JsonObjectCreationHandling.Replace matches System.Text.Json: read-only properties are not populated unless you opt into Populate via options or [JsonObjectCreationHandling].
using System.Text.Json.Serialization;
using Tomlyn.Serialization;
public sealed class MyConfig
{
public string? Global { get; set; }
}
[TomlSourceGenerationOptions(
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
PreferredObjectCreationHandling = JsonObjectCreationHandling.Replace)]
[TomlSerializable(typeof(MyConfig))]
internal partial class MyTomlContext : TomlSerializerContext
{
}
var config = TomlSerializer.Deserialize(toml, MyTomlContext.Default.MyConfig);
var tomlOut = TomlSerializer.Serialize(config, MyTomlContext.Default.MyConfig);
When a base type lives in one project and derived types live in another, you can register derived types without putting [TomlDerivedType] on the base type.
Reflection path:
using Tomlyn;
var options = new TomlSerializerOptions
{
PolymorphismOptions = new TomlPolymorphismOptions
{
TypeDiscriminatorPropertyName = "kind",
DerivedTypeMappings = new Dictionary<Type, IReadOnlyList<TomlDerivedType>>
{
[typeof(Animal)] =
[
new(typeof(Cat), "cat"),
new(typeof(Dog), "dog"),
],
},
},
};
Source generation path:
using Tomlyn.Serialization;
[TomlSerializable(typeof(Animal))]
[TomlDerivedTypeMapping(typeof(Animal), typeof(Cat), "cat")]
[TomlDerivedTypeMapping(typeof(Animal), typeof(Dog), "dog")]
internal partial class MyTomlContext : TomlSerializerContext
{
}
Use TomlPolymorphismOptions.DerivedTypeMappings and [TomlDerivedTypeMapping] additively with existing base-type attributes. Base-type registrations still take precedence when the same discriminator or derived type is registered more than once.
using System.Text.Json.Serialization;
using Tomlyn.Serialization;
public sealed class PackagingConfiguration
{
public PackagingConfiguration()
{
RuntimeIdentifiers = new List<string>();
}
[TomlSingleOrArray]
[JsonPropertyName("rid")]
public List<string> RuntimeIdentifiers { get; }
}
With [TomlSingleOrArray], both of these TOML payloads are valid:
rid = "win-x64"
rid = ["win-x64", "linux-x64"]
For mutable read-only collection members, Tomlyn appends into the existing collection instance. Without [TomlSingleOrArray], collection members still require a TOML array.
Reflection fallback can be disabled globally before first serializer use:
AppContext.SetSwitch("Tomlyn.TomlSerializer.IsReflectionEnabledByDefault", false);
When publishing with NativeAOT (PublishAot=true), the Tomlyn NuGet package disables reflection-based serialization by default.
You can override the default by setting the following MSBuild property in your app project:
<PropertyGroup>
<TomlynIsReflectionEnabledByDefault>true</TomlynIsReflectionEnabledByDefault>
</PropertyGroup>
This software is released under the BSD-Clause 2 license.
Alexandre Mutel aka xoofx.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 3 NuGet packages that depend on Tomlyn.Signed:
| Package | Downloads |
|---|---|
|
Snowflake.Data
Snowflake Connector for .NET |
|
|
Microsoft.ComponentDetection.Detectors
Package Description |
|
|
CloudPub.Client
The CloudPub C# SDK provides a simple interface for interacting with the CloudPub platform. CloudPub provides secure tunneling and service publishing, allowing you to securely expose local services to the internet. |
Showing the top 3 popular GitHub repositories that depend on Tomlyn.Signed:
| Repository | Stars |
|---|---|
|
microsoft/component-detection
Scans your project to determine what components you use
|
|
|
influxdata/influxdb-client-csharp
InfluxDB 2.x C# Client
|
|
|
snowflakedb/snowflake-connector-net
Snowflake Connector for .NET
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.7.0 | 0 | 6/18/2026 |
| 2.6.0 | 426 | 6/12/2026 |
| 2.5.0 | 479 | 6/7/2026 |
| 2.4.2 | 212 | 6/5/2026 |
| 2.4.1 | 769 | 5/28/2026 |
| 2.4.0 | 1,447 | 5/11/2026 |
| 2.3.2 | 1,703 | 4/22/2026 |
| 2.3.1 | 456 | 4/22/2026 |
| 2.3.0 | 2,229 | 3/29/2026 |
| 2.2.1 | 625 | 3/24/2026 |
| 2.2.0 | 523 | 3/24/2026 |
| 2.1.0 | 480 | 3/24/2026 |
| 2.0.1 | 483 | 3/24/2026 |
| 2.0.0 | 448 | 3/17/2026 |
| 1.2.0 | 603 | 3/11/2026 |
| 1.1.1 | 566 | 3/8/2026 |
| 1.1.0 | 336 | 3/6/2026 |
| 1.0.0 | 464 | 3/4/2026 |
| 0.20.0 | 26,136 | 1/24/2026 |
| 0.19.0 | 275,866 | 3/11/2025 |