ConScript is a powerful configuration management library designed for .NET developers who need a robust, secure, and flexible way to handle application settings. With its intuitive API and comprehensive feature set, ConScript simplifies configuration management while providing advanced capabilities like encryption, validation, and hierarchical organization.
| π Secure | AES-256 encryption for sensitive configuration with full thread safety |
| π§© Flexible | Hierarchical configuration with nested blocks and dot notation access |
| β Type-safe | Strongly typed access with automatic conversion between types |
| π¦ Validated | Custom validation rules with descriptive error messages |
| π Reactive | Event-based notification system for tracking configuration changes |
| β‘ Performant | Optimized for speed with compiled regex patterns and concurrent collections |
| π Documented | Comments support in configuration files with preservation during save |
| π§ͺ Extensible | Pluggable architecture with interfaces for custom implementations |
Install ConScript via NuGet Package Manager:
dotnet add package ConScriptOr via the Package Manager Console:
Install-Package ConScript// Create a new configuration instance
var config = new ConScript();
// Load configuration from file
var result = config.Load("config.cosc");
if (!result.Success)
{
Console.WriteLine($"Error: {result.Message}");
return;
}
// Access configuration values with type safety
int maxHealth = config.GetInt("maxHealth");
string playerName = config.GetString("player.name");
float moveSpeed = config.GetFloat("player.moveSpeed");
// Modify configuration with fluent API
config.Set("maxHealth", 200)
.WithComment("Maximum player health")
.WithValidation<int>(v => v > 0, "Health must be positive");
// Save configuration
config.Save("config.cosc");ConScript provides intuitive access to nested configuration:
// Access nested values with dot notation
int strength = config.GetByPath<int>("player.stats.strength");
float speed = config.GetByPath<float>("player.stats.speed");
// Array access
List<string> abilities = config.GetList<string>("player.abilities");Protect sensitive configuration data with built-in encryption:
// Load encrypted configuration
var config = new ConScript();
var result = config.Load("secure-config.cosc", "your-password");
// Make changes
config.Set("database.connectionString", "Server=myserver;Database=mydb;User Id=username;Password=password;");
// Save with encryption (uses the password from loading)
config.Save("secure-config.cosc");Track changes to configuration values:
// Subscribe to configuration changes
config.ValueChanged += (sender, args) => {
Console.WriteLine($"[CONFIG] Value '{args.Key}' changed:");
Console.WriteLine($" From: {args.OldValue}");
Console.WriteLine($" To: {args.NewValue}");
// Trigger application logic based on changes
if (args.Key == "logging.level") {
UpdateLoggingLevel(args.NewValue);
}
};ConScript uses a clean, readable format inspired by modern configuration languages:
// Server configuration
server {
// Network settings with validation
network {
int port = 8080;
string ip = "127.0.0.1";
bool enableUpnp = true;
};
// Performance settings
performance {
int maxPlayers = 64;
float tickRate = 64.0;
int[] workerThreads = [2, 4, 8];
};
};
// Player settings
player {
string name = "DefaultPlayer";
float moveSpeed = 5.0;
// Player statistics block
stats {
int health = 100;
int armor = 50;
string[] abilities = ["jump", "run", "swim"];
};
};
Implement your own encryption service by implementing the IEncryptionService interface:
public class CustomEncryptionService : IEncryptionService
{
public string Encrypt(string plainText, string password)
{
// Your custom encryption logic
}
public (OperationResult Result, string DecryptedText) Decrypt(string encryptedText, string password)
{
// Your custom decryption logic
}
}
// Use your custom encryption service
var config = new ConScript(new CustomEncryptionService());Ensure configuration values meet specific requirements:
// Set server port with validation
config.Set("server.network.port", 8080)
.WithValidation<int>(port => port >= 1024 && port <= 65535,
"Port must be between 1024 and 65535");
// Set player name with validation
config.Set("player.name", "Player1")
.WithValidation<string>(name => !string.IsNullOrEmpty(name) && name.Length <= 20,
"Player name must be between 1 and 20 characters");ConScript is designed with performance in mind:
- Uses
ConcurrentDictionaryfor thread-safe operations - Implements reader-writer locks for optimized concurrent access
- Pre-compiles regex patterns for faster parsing
- Employs lazy value conversion to minimize unnecessary processing
| Class | Description |
|---|---|
ConScript |
Main configuration class that implements IConfigurationProvider |
ConfigurationBuilder |
Fluent API for configuration operations |
OperationResult |
Result pattern for operations that may succeed or fail |
| Interface | Description |
|---|---|
IConfigurationProvider |
Core configuration operations |
IConfigurationBuilder |
Fluent API for building configurations |
IEncryptionService |
Interface for custom encryption implementations |
ConScript is licensed under the MIT License. See the LICENSE file for details.
MIT License
Copyright (c) 2025 TheYIMIR
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Contributions are welcome! Here's how you can contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please make sure to update tests as appropriate and adhere to the existing coding style.
- Developed by TheYIMIR
- Built with .NET 8.0
- Inspired by modern configuration systems
Made with β€οΈ by Tecca
Copyright Β© 2025