Documentation
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, and small collections.
Installation
dotnet add package ArturRios.Util
The package targets net10.0 and depends on ArturRios.Output, which provides result envelopes.
Quickstart
Collections
using ArturRios.Util.Collections; Console.WriteLine($"{AnsiColors.Green}Success!\x1b[0m"); var pool = Characters.Digits + Characters.UpperLetters;Console
using ArturRios.Util.Console; CustomConsole.WriteCharLine(); // 100 dashes CustomConsole.WriteCharLine('=', 40); // 40 equals signsFlowControl
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.Wait(); } }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 FileReaderAsyncMath
using ArturRios.Util.Math; bool isPrime = PrimeUtils.IsPrimeNumber(7919); // true var generator = new PrimeGenerator<int>(); Console.WriteLine(generator.Next()); // 2 Console.WriteLine(generator.Next()); // 3Random
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, IncludeSpecialCharacters = true });RegularExpressions
using ArturRios.Util.RegularExpressions; var isEmail = RegexCollection.Email().IsMatch("john@doe.com"); var stripped = RegexCollection.HasNumber().Remove("abc123def"); // "abcdef"
Detailed documentation
Full API reference, class diagrams, and usage examples:
Versioning
Semantic Versioning (SemVer). Breaking changes result in a new major version. New methods or non-breaking behavior changes increment the minor version; fixes or tweaks increment the patch.
Build, test and publish
Use the official .NET CLI to build, test and publish the project and Git for source control. If you want, optional helper toolsets I built to facilitate these tasks are available:
Legal Details
This project is licensed under the MIT License. A copy of the license is available at LICENSE in the repository.