Chasm.Utilities
2.3.7
See the version list below for details.
dotnet add package Chasm.Utilities --version 2.3.7
NuGet\Install-Package Chasm.Utilities -Version 2.3.7
<PackageReference Include="Chasm.Utilities" Version="2.3.7" />
paket add Chasm.Utilities --version 2.3.7
#r "nuget: Chasm.Utilities, 2.3.7"
// Install Chasm.Utilities as a Cake Addin #addin nuget:?package=Chasm.Utilities&version=2.3.7 // Install Chasm.Utilities as a Cake Tool #tool nuget:?package=Chasm.Utilities&version=2.3.7
Chasm.Utilities
Provides various utility types and methods.
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 string textA) { /* ... */ }
else if (b is string textB) { /* ... */ }
else if (c is string textC) { /* ... */ }
// Using Util.Is:
if (a is string text) { /* ... */ }
else if (Util.Is(b, out text)) { /* ... */ }
else if (Util.Is(c, out text)) { /* ... */ }
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 a 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
makes use of this class.
ReaderWriterLockSlim rwl = new();
// Commonly written as:
try
{
rwl.EnterReadLock();
/* ... */
}
finally
{
rwl.ExitReadLock();
}
// Using ReaderWriterLockSlimExtensions:
using (rwl.WithReaderLock())
/* ... */
Product | Versions 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 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. |
.NET Core | netcoreapp1.0 is compatible. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. 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. |
-
.NETCoreApp 1.0
- Microsoft.NETCore.App (>= 1.0.5)
-
.NETCoreApp 3.0
- No dependencies.
-
.NETFramework 3.5
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 1.0
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 2.1
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.5.2 | 88 | 9/28/2024 |
2.5.1 | 115 | 9/6/2024 |
2.5.0 | 94 | 9/6/2024 |
2.4.0 | 98 | 9/5/2024 |
2.3.7 | 68 | 7/30/2024 |
2.3.6 | 94 | 6/11/2024 |
2.3.5 | 97 | 6/7/2024 |
2.3.4 | 106 | 5/9/2024 |
2.3.3 | 304 | 1/2/2024 |
2.3.2 | 171 | 1/1/2024 |
2.3.1 | 140 | 12/30/2023 |
2.3.0 | 121 | 12/29/2023 |
2.2.0 | 123 | 12/17/2023 |
2.1.0 | 121 | 12/16/2023 |
2.0.0 | 127 | 12/16/2023 |