LiteConfig 1.0.4
dotnet add package LiteConfig --version 1.0.4
NuGet\Install-Package LiteConfig -Version 1.0.4
<PackageReference Include="LiteConfig" Version="1.0.4" />
<PackageVersion Include="LiteConfig" Version="1.0.4" />
<PackageReference Include="LiteConfig" />
paket add LiteConfig --version 1.0.4
#r "nuget: LiteConfig, 1.0.4"
#:package LiteConfig@1.0.4
#addin nuget:?package=LiteConfig&version=1.0.4
#tool nuget:?package=LiteConfig&version=1.0.4
LiteConfig (.lc) Library

LiteConfig (.lc) is a lightweight configuration file format designed for ease of use primacy.
Features
- Types: Read values in standard types int, float, double, bool, and string with dedicated methods - Other types will attempt to be dynamically understood
- Dictionary: Optionally cache your config file using the included Data property for dictionary access
- Fidelity: Writes update a key where it stands. Comments, blank lines, ordering, indentation, encoding and line endings all survive
- Portability: All parsing and formatting is culture invariant, so a file reads the same on every machine
- Simplicity: LC is designed to be a very barebones format, and as such very few "extras" are included
The exact grammar is in SPEC.md.
Installation
Using NuGet:
Install-Package LiteConfig
Example File
# Single line comments
title: Example
shortForm: single-line strings do not require double quotes
longForm: "strings of text with multiple lines,
can be written by enclosing the whole block of text in double quotes."
firstToggle: True
secondToggle: false
whatDayIsIt: 01/01/1970
lines: 11
collection: item1, item2
collectionSize: 2.0
servers:
- alpha
- beta
Usage
using LiteConfig;
public class App
{
public App()
{
LC lc = new();
lc.LoadFromFile("config.lc");
string name = lc.Data["name"];
// OR
name = LC.ReadString("config.lc", "name");
// OR
name = LC.ReadValue<string>("config.lc", "name");
string item1 = LC.ReadList<string>("config.lc", "collection").ToArray()[0];
}
}
Writing updates the key in place and leaves the rest of the file alone:
LC.WriteValue("config.lc", "lines", 12); // Rewrites only that line
LC.WriteValue("config.lc", "newKey", 1); // Appended at the end
// Or change several values and save once
LC lc = new();
lc.LoadFromFile("config.lc");
lc.Data["lines"] = 12;
lc.Data["servers"] = new List<string> { "alpha", "gamma" };
lc.WriteToFile("config.lc");
Changes in 1.0.4
Parsing and writing were rebuilt on a shared scanner. Previously:
- A single-line quoted value such as
title: "Example"swallowed the rest of the file and produced no keys at all WriteValueon a key already present in the file did nothing, silently- Values in
Datathat were not strings were dropped on write, silently - Number and date parsing followed the current culture, so a file that read correctly in one locale threw in another
- A comment line with leading whitespace threw; a comment line inside a quoted value was deleted from the value
LoadFromFilemerged into whatever was already loaded instead of replacing itReadStringandReadListreturned null or threwNullReferenceExceptionon block-form lists- A missing key produced
KeyNotFoundExceptionfrom inside the error handler, discarding the intended message
All of the above are fixed. WriteToFile is now public, error messages carry line numbers, saves are
atomic, and ReadValue<T> also accepts enums and the boolean spellings yes, no, on, off, 1, 0.
An unterminated quoted value now raises an error rather than silently discarding the value.
Distribution and Usage Rights
You are granted full freedom and permission to:
- Distribute this library as you see fit, whether in its original form or in a modified version.
- Decompile and use any part of the code directly in your projects.
- Copy code from the repository, and use any part of the code directly in your projects.
- Bundle it within an executable or any other software structure.
- Re-purpose and use this library in any other manner you deem necessary.
In essence, you have carte blanche to utilize this library in any manner you choose. Please remember to respect the licensing agreement for any other third-party libraries or resources that LiteConfig may depend on.
License
This library is licensed under the GPL License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Parsing and writing rebuilt on a shared scanner. Single-line quoted values now parse. WriteValue updates an existing key in place instead of doing nothing. Comments, ordering, indentation, encoding and line endings survive a write. All parsing and formatting is culture invariant. WriteToFile is public, errors carry line numbers, and saves are atomic.