peSHIr.Core 1.0.1

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

About

What's this?

This 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.

What's so special about that?

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:

  • An interface plus some utility code for optionally supplying basic progress messages to callers/UI.
  • Formatting of values/messages for the purpose of showing information to (UIs used by) human users.
  • Parsing/unparsing string values to/from strongly typed values.
  • Some utility extension methods on sequences/collections.
  • Abstract base and concrete sub classes for working with sets and ranges.
  • Some math and calculation related code.

Who created this?

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.

How do I use it?

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.

The Dispose Pattern

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.

Operations showing progress

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.

Just go exploring...

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.

Download

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

License and Versioning

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.

Credits

This library wouldn't have been possible without the following:

Show your appreciation for my work

If you like what you see/use you could try one of these links to let me know:

You may also like

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on peSHIr.Core:

Package Downloads
peSHIr.Forms

Basic .NET library containing utility code related to Windows Forms applications, by the author of peSHIr.Core.

peSHIr.Speech

Very basic .NET library easy use of System.Speech in Windows Forms applications in Dutch/English, by the author of peSHIr.Core.

peSHIr.License

Basic .NET library to help with interpreting stdout from running a pre-installed lmutil.exe licensing commandline tool.

peSHIr.Drawing

Basic .NET library containing color and bitmap related utility code (re)used within the last decade by the author.

peSHIr.GEF

Basic .NET library to read Geotechnical Exchange Format (or *.gef) files used for cone penetration test (or CPT) data.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 128 8/14/2025
1.0.0 110 8/1/2025

Added a couple of methods to peSHIr.IO.FileSystem for working with files and folders, containing more extensive bits of error handling that might come in handy on environments with network (storage) that might be more flaky or restricted security-wise than you would like.