MutableConfig 1.0.3

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

MutableConfig

NuGet versionLicenseNuGet downloadsGitHub stars

A lightweight and extensible .NET/C# library for runtime configuration management, supporting type-safe mapping of C# classes to JSON files.

About

MutableConfig is a configuration management library for the .NET/C# environment. It is designed to allow applications to easily load, modify, and persist configuration items at runtime without needing to restart or redeploy. It supports organizing configurations into a hierarchical structure, dynamic updates, and is designed to be lightweight and extensible.

Common use cases include:

  • 🔄 Runtime Configuration Updates: When you have an application and need to change certain configuration items during runtime without stopping the application.

  • ðŸ§Đ C# to JSON Mapping: Map C# types to JSON files one by one, enabling strong-typed configuration access.

  • 🌐 Centralized Multi-Module Management: Want to centrally manage configurations across multiple modules/environments and support features like hot updates.

Key Features

Here are some of the key features of this library:

  • ⚙ïļ Runtime Mutable Configuration: Supports easily modifying configuration items with code during the application's runtime without needing to restart the application.

  • ðŸ§Đ Configuration File Hierarchy and Typed Access:

    • Maps C# classes to JSON files one-to-one, providing strong-typed access.
    • Configuration fields can be read and modified like regular C# objects.
    • Changes are persisted to the JSON file explicitly via the SaveChanges() method, keeping the file hierarchy consistent with the type definitions.
  • ðŸ’ū Persistence and Recovery Mechanism: Configuration changes can be saved persistently, allowing the previous state to be restored on the next startup.

  • ðŸŠķ Lightweight: Uses only core .NET features without relying on many external libraries, making it easy to embed and extend.

How to Use

Installation

dotnet add package MutableConfig

Add to Program.cs:

using MutableConfig;
// Configuration Data Preparation
const string configFolderName = "Config";
var basePath = Path.Join(AppContext.BaseDirectory, configFolderName);

var defaultAppSettingsConfig = new AppSettingsConfig {
    AppName = "MutableConfig Sample App", Version = "1.0.0", EnableDebug = true
};
var defaultDatabaseConfig = new DatabaseConfig {
    Host = "localhost", Port = 5432
};

/*
 * Dependency Injection
 *
 * AppSettingsConfig is a custom configuration class.
 * Once registered through dependency injection, MutableConfig will ensure that
 * an "AppSettingsConfig.json" file exists under the specified basePath.
 *
 * On the first run, if the configuration file does not exist, it will be created
 * using the default values provided through SetupDefaultConfigIfNotExists().
 *
 * Configuration objects are fully mutable at runtime, and changes made to them
 * are tracked within their corresponding ConfigContext<T>. To persist updates
 * to the underlying JSON file, you explicitly call SaveChanges() on the context.
 */
builder.Services.AddConfigContext<AppSettingsConfig>(opt =>
    opt.SetBasePath(basePath)
        .SetupDefaultConfigIfNotExists(defaultAppSettingsConfig));

Example

You can find a complete working example here:

👉 Sample Code

This sample demonstrates how to define a configuration class, bind it to a JSON file, and modify it at runtime while keeping both sides synchronized.

Main Types

The main types provided by this library are:

  • ConfigContext<T> — A configuration context for a specific type. Use ConfigContext<T> for a particular configuration class.
  • ConfigContextOptions<T> — Options for configuring a ConfigContext<T>.

Feedback & Contributing

MutableConfig is released as open source under the Apache-2.0 license. Bug reports and contributions are welcome at the GitHub repository.

Product 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. 
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.3.2 406 11/17/2025
1.3.1 407 11/17/2025
1.3.0 224 11/14/2025
1.2.0 232 11/14/2025
1.1.0 231 11/14/2025
1.0.3 291 11/13/2025
1.0.2 286 11/13/2025
1.0.1 288 11/13/2025
1.0.0 301 11/12/2025