Chasm.Utilities 3.0.0

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

Chasm.Utilities

Latest NuGet version MIT License

Provides various utility types and methods, for code that needs to be written quickly, and not necessarily efficiently.

[!WARNING] ████ Don't use this package in performance-critical scenarios! ████
Many methods don't get inlined properly, and even if they do, there's still some overhead.
As such, appropriate uses of this library would be: writing quick tests, proofs-of-concept and mock-ups.

Util

Contains various utility methods, that can be used to shorten common branch code. (or... you could also just not use the auto-formatting, and write everything in a single line, but that's not my style)

Util.Fail sets all out parameters to default and returns either false or a specified return value. Especially useful for parsing.

// Commonly written as:
if (stringIsInvalid) { result = null; return ErrorCode.InvalidString; }

// Using Util.Fail:
if (stringIsInvalid) return Util.Fail(ErrorCode.InvalidString, out result);

Util.Catch catches an exception thrown by the specified delegate. If the delegate returned a value, it can be read through an out parameter.

// Commonly written as:
object? result; Exception? ex;
try { result = doSomething(); ex = null; }
catch (Exception caught) { result = null; ex = caught; }

// Using Util.Catch:
var ex = Util.Catch(doSomething, out object? result);

Util.Is can be used to assign a type-casted value to an existing variable.

// Commonly written as:
if (a is BigInteger bigInt_1) { /* ... */ }
else if (b is BigInteger bigInt_2) { /* ... */ }
else if (c is BigInteger bigInt_3) { /* ... */ }

// Using Util.Is:
if (a is BigInteger bigInt) { /* ... */ }
else if (Util.Is(b, out bigInt)) { /* ... */ }
else if (Util.Is(c, out bigInt)) { /* ... */ }

Util.With can be used to invoke functions while using a IDisposable:

// Commonly written as:
string? firstLine;
using (StreamReader reader = File.OpenText(path))
    firstLine = reader.ReadLine();

// Using Util.With:
string? firstLine = Util.With(File.OpenText(path), reader => reader.ReadLine());

Util.Swap just swaps two values. Useful when the tuple swap is too long or prone to errors.

// Commonly written as:
(firstVariable, secondVariable) = (secondVariable, firstVariable);

// Using Util.Swap:
Util.Swap(ref firstVariable, ref secondVariable);

DelegateDisposable

DelegateDisposable is an IDisposable interface implementation that invokes an action on disposal.

store.Subscribe(listenerFunc);
var listener = new DelegateDisposable(() => store.Unsubscribe(listenerFunc));

// Or like this, functional programming style:
var listener = DelegateDisposable.Create(
    () => store.Subscribe(listenerFunc),
    () => store.Unsubscribe(listenerFunc)
);

ReaderWriterLockSlimExtensions

ReaderWriterLockSlimExtensions makes use of specialized variants of DelegateDisposable to enter and exit locks.

ReaderWriterLockSlim rwl = new();

// Commonly written as:
try
{
    rwl.EnterReadLock();
    /* ... */
}
finally
{
    rwl.ExitReadLock();
}

// Using ReaderWriterLockSlimExtensions:
using (rwl.WithReaderLock())
    /* ... */
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 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. 
.NET Core netcoreapp1.0 is compatible.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.0 is compatible.  netstandard1.1 was computed.  netstandard1.2 was computed.  netstandard1.3 was computed.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 is compatible. 
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wp8 was computed.  wp81 was computed.  wpa81 was computed. 
Windows Store netcore was computed.  netcore45 was computed.  netcore451 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 1.0

  • .NETCoreApp 2.1

    • No dependencies.
  • .NETCoreApp 3.0

    • No dependencies.
  • .NETFramework 3.5

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETStandard 1.0

  • .NETStandard 2.1

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Chasm.Utilities:

Package Downloads
GrammarSharp.Russian

Provides a bunch of classes, structures and methods pertaining to Russian declension of nouns, adjectives and pronouns.

GrammarSharp

Package Description

GrammarSharp.English

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 73 10 days ago
2.5.3 457 a month ago
2.5.2 117 7 months ago
2.5.1 255 8 months ago
2.5.0 106 8 months ago
2.4.0 111 8 months ago
2.3.7 78 9 months ago
2.3.6 105 6/11/2024
2.3.5 108 6/7/2024
2.3.4 117 5/9/2024
2.3.3 313 1/2/2024
2.3.2 181 1/1/2024
2.3.1 148 12/30/2023
2.3.0 133 12/29/2023
2.2.0 134 12/17/2023
2.1.0 129 12/16/2023
2.0.0 135 12/16/2023