PTrampert.IniUtils
2.5.0
dotnet add package PTrampert.IniUtils --version 2.5.0
NuGet\Install-Package PTrampert.IniUtils -Version 2.5.0
<PackageReference Include="PTrampert.IniUtils" Version="2.5.0" />
<PackageVersion Include="PTrampert.IniUtils" Version="2.5.0" />
<PackageReference Include="PTrampert.IniUtils" />
paket add PTrampert.IniUtils --version 2.5.0
#r "nuget: PTrampert.IniUtils, 2.5.0"
#:package PTrampert.IniUtils@2.5.0
#addin nuget:?package=PTrampert.IniUtils&version=2.5.0
#tool nuget:?package=PTrampert.IniUtils&version=2.5.0
PTrampert.IniUtils
Lightweight .NET library for reading INI files into a small in-memory model.
PTrampert.IniUtils focuses on a simple, predictable parser with an async API and a few useful options. It exposes an easy-to-use reader (IniReader) and small data types (IniFile, IniSection, IniOptions) that make consuming INI data straightforward.
Features
- Read INI data asynchronously from a
TextReader,Stream, or file path. - Preserve multiple values for the same key (duplicate keys append values).
- Configurable comment character and option to keep empty values.
- Simple in-memory model: sections (including a root section) with key → values mapping.
- Small surface area — no external dependencies required by the library itself.
- Automatic includes resolution (e.g.
Include = otherfile.ini).
Install
Install from NuGet (package id: PTrampert.IniUtils):
# install the package
dotnet add package PTrampert.IniUtils
If you consume the project as a package, use the package ID and version that corresponds to the published NuGet package.
Quick start / Usage
Basic usage (from code):
using PTrampert.IniUtils;
var options = new IniOptions();
var reader = new IniReader(options);
// 1) Read from a TextReader (core overload)
using var sr = new StringReader("key1=value1\nkey2=value2");
var iniFromTextReader = await reader.ReadAsync(sr);
// 2) Read from a Stream
using var fs = File.OpenRead("config.ini");
var iniFromStream = await reader.ReadAsync(fs);
// 3) Read directly from a file path
var iniFromFile = await reader.ReadAsync("path/to/config.ini");
// Working with results
var root = iniFromFile.Sections[""]; // root section stored under empty string
if (root.KeyValues.TryGetValue("key1", out var values))
{
foreach (var v in values)
{
Console.WriteLine(v);
}
}
Optional behaviors controlled by IniOptions:
CommentCharacter(char) — change the character that marks a full-line comment (default is ';').KeepEmptyValues(bool) — if true, keys with empty values are kept; otherwise they are ignored.
You can also pass a custom IniSection as the rootSection parameter to any ReadAsync overload to start with a pre-populated root section.
Build and test
From the repository root:
# build
dotnet build
# run tests
dotnet test
The test project uses NUnit and validates parsing behavior across the available ReadAsync overloads.
Contributing
Contributions, bug reports, and pull requests are welcome. Please include tests for new behavior and keep public API changes small and well-documented.
License
This project is licensed under the MIT License — see the LICENSE file for details.
| 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | 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.1
- 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.