RansauSysteme.Utils 1.3.0

dotnet add package RansauSysteme.Utils --version 1.3.0
                    
NuGet\Install-Package RansauSysteme.Utils -Version 1.3.0
                    
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="RansauSysteme.Utils" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RansauSysteme.Utils" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="RansauSysteme.Utils" />
                    
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 RansauSysteme.Utils --version 1.3.0
                    
#r "nuget: RansauSysteme.Utils, 1.3.0"
                    
#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 RansauSysteme.Utils@1.3.0
                    
#: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=RansauSysteme.Utils&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=RansauSysteme.Utils&version=1.3.0
                    
Install as a Cake Tool

RansauSysteme.Utils

A comprehensive collection of utility methods for .NET Core/.NET 8 applications, providing robust solutions for common development tasks.

Installation

Install the package from NuGet:

dotnet add package RansauSysteme.Utils

Or using the Package Manager Console:

Install-Package RansauSysteme.Utils

Features

String Utilities

The StringUtils class provides various string manipulation methods:

// Convert strings to different cases
string snakeCase = "MyVariable".ToSnakeCase(); // "my_variable"
string capitalized = "hello world".Capitalize(); // "Hello World"
string camelCase = "user_first_name".ToCamelCase(); // "userFirstName"

// Other string operations
string truncated = "This is a long text".Truncate(10); // "This is a..."

I/O Utilities

The IOUtils class makes file and directory operations more robust:

// Create files and directories safely
IOUtils.CreateFile("path/to/new/file.txt");

// Copy directories recursively
IOUtils.CopyDirectory("source", "destination");

// Create timestamped filenames
string filename = IOUtils.DatetimeFilename(DateTime.Now); // "2025-02-26_15-30-00"

JSON Utilities

The JsonUtils class simplifies working with JSON:

// Serialize objects to JSON
string json = JsonUtils.ToJson(myObject);

// Deserialize JSON to objects
MyClass? obj = JsonUtils.ParseJson<MyClass>(jsonString);

// Load JSON from files
Configuration? config = JsonUtils.ParseFile<Configuration>("config.json");

// Save objects as JSON files
JsonUtils.SaveToFile(myObject, "data.json");

Database Utilities

The DatabaseUtils class helps with database-related operations:

// Generate secure random passwords
string password = DatabaseUtils.GeneratePassword(length: 12);

// Validate passwords against security requirements
bool isValid = DatabaseUtils.IsValidPassword(
    password, 
    minPasswordLength: 8,
    requireUppercase: true,
    requireLowercase: true,
    requireDigit: true,
    requireSpecialChar: true
);

// Or use predefined security levels
bool isValid = DatabaseUtils.IsValidPassword(
    password, 
    strength: PasswordStrength.VeryStrong
);

Result Pattern

The Result<T> class provides a clean way to handle operation results:

// Create success results
Result<User> userResult = Result<User>.Success(user);

// Create failure results
Result<User> failedResult = Result<User>.Failure("User not found");

// Use in methods
public Result<User> GetUser(int id)
{
    var user = _repository.FindById(id);
    if (user == null)
        return Result<User>.Failure("User not found");
    
    return Result<User>.Success(user);
}

// Check results
if (result.IsSuccess)
{
    // Use result.Data
}
else
{
    // Handle error using result.Error
}

Build Utils

The BuildUtils class provides information about the current build:

// Check if running in debug mode
if (BuildUtils.IsDebug)
{
    // Do additional logging
}

// Get environment information
string summary = BuildUtils.GetSummary();
// "Build Configuration: Debug
//  Version: 1.0.0.0
//  OS: Windows
//  Process: 64-bit
//  Build Date: 2025-02-26 15:30:00"

Requirements

  • .NET 8.0 or higher

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on RansauSysteme.Utils:

Package Downloads
RansauSysteme.Database

A flexible .NET data access library implementing the Repository pattern for database operations. Features include: - Generic repository implementation with full CRUD operations - Support for MySQL databases with extensible design for other providers - Both synchronous and asynchronous API - Efficient batch operations with transaction support - Built-in caching repository with configurable refresh intervals - Factory pattern for creating repositories with dependency injection support - Comprehensive error handling with custom exceptions - Thread-safe implementation for concurrent applications Designed for developers who want a clean, maintainable approach to database access in .NET applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 252 10/16/2025
1.2.0 267 10/1/2025