Collections
ANSI colour escape sequences and the character pools that random string generation and validation draw from.
Utilities for common development tasks in .NET: console output helpers, flow control (conditions, retries, and waiters), hashing (Argon2id), file I/O helpers, HTTP client helpers, math utilities, random values and strings, regex helpers, text and email helpers, and small collections.
dotnet add package ArturRios.Util
The package targets net10.0 and depends on ArturRios.Output (result envelopes) and
Konscious.Security.Cryptography.Argon2 (the Argon2id implementation).
Collections
using ArturRios.Util.Collections;
Console.WriteLine($"{AnsiColors.Green}Success!{AnsiColors.Reset}");
var pool = Characters.Digits + Characters.UpperLetters;
Console
using ArturRios.Util.Console;
CustomConsole.WriteCharLine(); // 100 dashes
CustomConsole.WriteCharLine('=', 40); // 40 equals signs
FlowControl
using ArturRios.Util.FlowControl;
using ArturRios.Util.FlowControl.Waiter;
Condition.Create
.True(user is not null).FailsWith("User is required")
.True(emailValid).FailsWith("Invalid email")
.ThrowIfNotSatisfied();
Retry.New.MaxAttempts(3).DelayMilliseconds(200).Execute(() => DoFragileWork());
var result = Retry.New.MaxAttempts(5).Execute(() => Compute());
var waiter = new JitteredWaiter(maxRetryCount: 5);
while (waiter.CanRetry)
{
try { await TryOperationAsync(); break; }
catch { await waiter.WaitAsync(); }
}
Hashing
using ArturRios.Util.Hashing;
var hash = Hash.EncodeWithRandomSalt("secret", out var salt);
var ok = Hash.TextMatches("secret", hash, salt);
Http
using ArturRios.Util.Http;
var gateway = new HttpGateway(httpClient);
var output = await gateway.GetAsync<MyResponse>("/api/items");
if ((int)output.StatusCode == HttpStatusCodes.Ok)
Console.WriteLine(output.Body);
IO
using ArturRios.Util.IO;
var text = FileReader.Read(path);
var lines = FileReader.ReadLines(path);
var dict = FileReader.ReadAsDictionary(path, ',');
var obj = FileReader.ReadAndDeserialize<MyType>(jsonPath);
// Async variants available on FileReaderAsync
Math
using ArturRios.Util.Math;
bool isPrime = PrimeUtils.IsPrimeNumber(7919); // true
var generator = new PrimeGenerator<int>();
Console.WriteLine(generator.Next()); // 2
Console.WriteLine(generator.Next()); // 3
Random
using ArturRios.Util.Random;
var n = CustomRandom.NumberFromRng(1, 10);
var n2 = CustomRandom.NumberFromSystemRandom(0, 100, differentFrom: 42);
var pwd = CustomRandom.Text(new RandomStringOptions { Length = 16 }); // all sets on by default
var pin = CustomRandom.Text(new RandomStringOptions
{
Length = 6, IncludeLowercase = false, IncludeUppercase = false, IncludeSpecialCharacters = false
});
RegularExpressions
using ArturRios.Util.RegularExpressions;
var isEmail = RegexCollection.Email().IsMatch("[email protected]");
var stripped = RegexCollection.HasNumber().Remove("abc123def"); // "abcdef"
Text
using ArturRios.Util.Text;
var missing = "ab1".Missing(CharacterClasses.Upper | CharacterClasses.Special); // Upper | Special
var ok = EmailAddress.TryNormalize("[email protected]", out var address); // "[email protected]"
Full API reference, class diagrams, and usage examples:
This project is licensed under the Artur Rios Attribution License. It is free and open source: you may view, use, fork, modify, and extend it, provided you credit the author, Artur Rios, with a link to artur-rios.tech or github.com/artur-rios.
ANSI colour escape sequences and the character pools that random string generation and validation draw from.
Helpers for writing formatted output to the system console.
Conditions that collect every failure before throwing, a reusable retry policy, and an exponential-backoff waiter with jitter.
Argon2id password hashing with configurable cost parameters and a constant-time comparison.
A typed HttpClient wrapper that returns status, headers and a deserialized body in a single envelope.
Synchronous and asynchronous file readers for text, lines, delimited data and JSON.
Primality tests for every built-in integer type and BigInteger, plus a generic prime generator.
Cryptographically strong random numbers and strings, with optional exclusion constraints.
Source-generated compiled regular expressions for email and character-class checks, with a match timeout.
Allocation-free character class checks and email normalization, offered alongside the equivalent regex patterns.
Notable changes in each release.
Building from source, running the tests, branching and releasing.