TinyIni 1.0.1
dotnet add package TinyIni --version 1.0.1
NuGet\Install-Package TinyIni -Version 1.0.1
<PackageReference Include="TinyIni" Version="1.0.1" />
<PackageVersion Include="TinyIni" Version="1.0.1" />
<PackageReference Include="TinyIni" />
paket add TinyIni --version 1.0.1
#r "nuget: TinyIni, 1.0.1"
#:package TinyIni@1.0.1
#addin nuget:?package=TinyIni&version=1.0.1
#tool nuget:?package=TinyIni&version=1.0.1
Tiny Ini
Is a small source generator which generates methods for serializing and deserializing structs.
Serialization
[TinyIni.IniSerializable]
public struct Config
{
public int Version = 0;
public Display Display = new()
{
Height = 1080,
Width = 1920,
VSync = VSync.Enabled
};
public Graphics Graphics = new()
{
MSAA = 16,
Advanced = new AdvancedGraphics
{
GraphicsAPI = GraphicsAPI.Vulkan
}
};
public Input InputKeyboard = new()
{
JumpKey = 32
};
public Input InputGamepad = new()
{
JumpKey = 16
};
public Config() {}
}
<details> <summary>[omitted for brevity]</summary>
public struct Graphics
{
public byte MSAA;
public AdvancedGraphics Advanced;
}
public struct AdvancedGraphics
{
public GraphicsAPI GraphicsAPI;
}
public struct Display
{
public int Width;
public int Height;
public VSync VSync;
}
public struct Input
{
public byte JumpKey;
}
public enum VSync
{
Enabled,
Disabled,
Adaptive
}
public enum GraphicsAPI
{
Vulkan,
DirectX12
}
</details>
TinyIni.Save("config.ini", in config);
<sub>config.ini</sub>
Version=0
[Display]
Width=1920
Height=1080
VSync=Enabled
[Graphics]
MSAA=16
[Graphics/Advanced]
GraphicsAPI=Vulkan
[InputKeyboard]
JumpKey=32
[InputGamepad]
JumpKey=16
Deserialization
TinyIni.Load("config.ini", ref config);
Installation
Install through NuGet
dotnet add package TinyIni
Local install
Clone this repository into your solution directory. </br>
git clone https://github.com/AQtun81/TinyIni </br>
Add analyzer reference in your project
<ItemGroup>
<ProjectReference Include="..\TinyIni\TinyIni.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"/>
</ItemGroup>
Compile your project
You won't see IntelliSense for any generated code until the project is built at least once.
Add [TinyIni.IniSerializable] attribute above any struct you wish to serialize
[TinyIni.IniSerializable]
public struct Config
{
// ...
Use the generated Load and Save methods
// this will additionally create a new file if one isn't already present
TinyIni.Load($"config.ini", ref config);
// this will generate new fields and remove obsolete ones
TinyIni.Save($"config.ini", in config);
FAQ
Unity support
You'll have to do some additional steps in order to use Tiny Ini with Unity.
git clone https://github.com/AQtun81/TinyIni- Inside of
TinyIni.csprojdowngradeMicrosoft.CodeAnalysis.CommonandMicrosoft.CodeAnalysis.CSharpto4.3.0-3.final - Uncomment
//#define TINY_INI_COMPATIBILITYinside ofProgram.csto enable support for older versions of C# - Build the project for release
dotnet build -c release - Copy the dll file to somewhere inside of your
Assetsfolder - Click on the .dll file to open the Plugin Inspector window
- Uncheck
Any Platform,EditorandStandalonecheckmarks, under Asset Labels create and assign a new label calledRoslynAnalyzer
Refer to Unity's documentation for more details.
Godot support
Godot 4 C# projects use MSBuild so following the default instructions for C# projects will work. </br> Versions prior to that are not supported.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.Common (>= 4.14.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.14.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.