SimpleTomlConfig 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleTomlConfig --version 1.0.0
                    
NuGet\Install-Package SimpleTomlConfig -Version 1.0.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="SimpleTomlConfig" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleTomlConfig" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SimpleTomlConfig" />
                    
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 SimpleTomlConfig --version 1.0.0
                    
#r "nuget: SimpleTomlConfig, 1.0.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 SimpleTomlConfig@1.0.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=SimpleTomlConfig&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SimpleTomlConfig&version=1.0.0
                    
Install as a Cake Tool

SimpleTomlConfig

SimpleTomlConfig is a small generic helper for managing TOML configuration files in .NET applications.

Features

  • Automatically loads and saves TOML files.
  • Creates a new configuration file with default values when the file does not exist.
  • Uses a generic base class so the same pattern can be reused across many configuration types.

Notes

  • If the configuration file does not exist, it is created from the current default property values.
  • Changes are not written to disk until Save() is called.
  • By default, TOML keys use the class or property name.
  • Use [TomlProperty("key")] to map a property to a different TOML key.
  • Use [TomlProperty] or [TomlSection] without a name to use the class or property name as-is.
  • Use [TomlSection("sectionName")] or [TomlSection] to save an object as a TOML section/table.
  • Use [TomlIgnore] to exclude a property from both loading and saving.
  • If configPath is not provided, a class that inherits TomlConfig<TClass> uses {TClass}.toml as the default file name.

Usage

1. Define a Configuration Class

using SimpleTomlConfig;

[TomlSection]
public class MyConfig(string? configPath = null) : TomlConfig<MyConfig>(configPath)
{
    [TomlProperty]
    public string? Name { get; set; }

    [TomlProperty("age")]
    public int Age { get; set; }

    [TomlIgnore]
    public string RuntimeOnlyValue { get; set; } = "";

    [TomlProperty("myType")]
    public MyEnum MyType { get; set; }

    [TomlSection("Device")]
    public DeviceConfig Device { get; set; } = new();
}

public class DeviceConfig
{
    public string Port { get; set; } = "COM1";
}

This produces TOML similar to:

[MyConfig]
Name = "Camera"
age = 3
myType = "Default"

[MyConfig.Device]
Port = "COM1"

2. Create a Configuration Instance

var config = new MyConfig();
var customConfig = new MyConfig("path/to/custom/config.toml");

3. Read Values

Console.WriteLine(config.Name);
Console.WriteLine(config.Device.Port);

4. Change and Save Values

config.Name = "Mr.Kim";
config.Device.Port = "COM3";
config.Save();

5. Reload Values

config.Load();

6. Save to Another Path

config.SaveAs("path/to/new/config.toml");
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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 159 5/11/2026
1.0.0 133 5/11/2026