Basic .NET library containing utility code (re)used within the last decade (or longer) by the author.
$ dotnet add package peSHIr.CoreThis library contains some utility functions I have been developing over the last decade or so (some even longer) and that I use extensively in almost anything I write/maintain these days.
There might not be anything really special about this, but maybe you think some of this is useful in your daily .NET developing life? These include things like:
My name is Jarno Peschier. I started programming on a Commodore 64 in high school, got a masters degree in Computer Science at Utrecht University at the end of the last century, specializing in GIS algorithms, and I have been developing software all my professional life.
You might also know me by my online name of peSHIr, which is basically the way you write my last name phonetically in Klingon.
At the start of 2025 I worked as a software engineer at Dutch engineering firm Iv, where I personally handled all software development around our scan vehicle (YouTube) using multiple third party software packages, C#, and PowerShell.
The laserscan and photo data Iv collects using this vehicle is used in infrastructure projects all over the Netherlands, but also for monitoring things like trees or quay walls in Amsterdam.
For some of the content it might just be a matter of using the correct namespace to activate a class of extension methods and start calling these methods.
One example of this would be to flatten a sequence of sequences into a flat sequence like this:
using peSHIr.Collections;
//...
IEnumerable<List<int>> values = [[1, 2, 3, 4, 5], [99], [2024,2025]];
IEnumerable<int>? flat = values.Flatten();
This is also true of the code from a blog post of mine from 2011, that literally works as described there, except that here you also find it in the peSHIr.Collections namespace instead of in the peSHIr.Utilities used as an example in the blog post.
There is a peSHIr.DisposableBase abstract class that implements the Dispose Pattern correctly for you.
All you need to do is derive from it, and override any of the three DisposeWhatever() virtual methods that make sense for your class to have it do cleanup.
Also, don't forget to use HasAlreadyBeenDisposed and NotWhenAlreadyDisposed() protected members as needed within your class members.
For me an important part of this package is the IShowProgress interface from the peSHIr.Progress namespace:
public interface IShowProgress
{
void Begin(string activity, string? description);
void Progress(long current, long total, string? description = null);
void Warning(string message);
void Done();
}
Quite a number methods in software that I write takes a IShowProgress? shell = null parameter, so it has a way of signaling to an "outside shell or user interface" that it is busy doing something, possibly showing progress or warning messages in the process.
At the start of a possible lengthy operation such a method calls Begin(), and at the end it calls Done(). When approriate, between these two calls Progress() can be called to give progress bar like progress indications, and possible warning messages (that the methods thinks are not exceptions, but could perhaps be shown somewhere to either a human user or log file) can be supplied by calling Warning().
There are extension methods on the interface (that also do nothing with any progress indications on a null instance), like overloads of ShowProgress() that for instance take an IList<T> and you could use instead of a for loop over the list, or ShowWarning() to try and show a warning.
A number of concrete implementations of the interface itself are supplied as wel, like KeepWarningsOnly (wrapper around another IShowProgress instance that only lets through the warnings), ThrowWarningsAsInvalidOperationExceptions (for when you really don't expect any warnings), peSHIr.CmdLine.ConsoleProgress (writes progress using Console.WriteLine), and peSHIr.Forms.FormWithProgress from our WinForms package that automatically shows a busy cursor and supports showing progress through a series of optional ToolStripItem controls used on the form.
Even if you never do anything with this interface, at least you know what those parameters might be for that you see popping up from time to time.
There is much more available, but you should be able to find this using IntelliSense yourself. Public members should all be documentated, and in future more information might appear here.
This library is available as a NuGet package on https://nuget.org. To install it, use the following command-line:
dotnet add package peSHIr.Core
This library is licensed under the MIT License - please see the LICENSE file for details - and makes use of Semantic Versioning to try and give meaning to the version numbers, at least for the non-prereleased stuff.
This library wouldn't have been possible without the following:
If you like what you see/use you could try one of these links to let me know: