LrndefLib provides a version-based config file
The config file implementation provided by TShock can't differentiate between config versions without iterating the whole file. LrndefLib provides an alternative implementation that instead compares a single property "metadata:version". However, the schema isn't strictly enforced
LrndefLib allows for config migrations during parsing. However, you need to provide your own migration implementation. LrndefLib can't migrate by default, it binds the config 1:1 as if it were any other version
Migrations can be implemented by modifying VersionedConfigFile.BindDelegate
. The delegate is called in the middle of parsing to bind a JObject
to a config object
- Open NuGet
- Search for "LrndefLib"
- Install
- Add
http https://github.com/Arthri/LrndefLib/releases/download/[VERSION]/LrndefLib.[VERSION].nupkg packages/LrndefLib/[VERSION]/LrndefLib.[VERSION].nupkg
to yourpaket.dependencies
- Replace
[VERSION]
with your desired version. DO NOT uselatest
.
- Replace
- Add
source paket-files/github.com/packages
, also topaket.dependencies
- Reference in projects via
paket.references
- Run
dotnet paket install
- Create a new instance of
VersionedConfigFile
like so:var configFile = new VersionedConfigFile<TSettings>(CurrentVersion);
- replace
TSettings
with the settings class - replace
CurrentVersion
with the current version of the config
- replace
- Read the config file:
configFile.Read(configPath, out bool _)
;
A config's "CurrentVersion
" is its latest iteration. Ideally, it should follow SemVer. Since configs change rarely, ideally, CurrentVersion
should NOT be derived from the assembly version