Ubiquity.NET.Extensions 20.1.8-rc.3

This is a prerelease version of Ubiquity.NET.Extensions.
There is a newer version of this package available.
See the version list below for details.

Requires NuGet 4.9.0 or higher.

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

About

Ubiquity.NET.Extensions contains general extensions for .NET. This is a bit of a "grab bag" of functionality used by but not actually part of multiple other Ubiquity.NET projects. A core principal is that this library has NO dependencies beyond the runtime itself. That is, this library should remain at the bottom of any dependency chain.

Key support

  • Computing a hash code for a ReadOnlySpan of bytes using System.IO.System.IO.Hashing.XxHash3
  • DisposableAction for building actions that must occur on Dispose
    • This is useful for implementing the RAII pattern in .NET.
  • MustUseReturnValueAttribute that is compatible with the MustUseRetVal package.
  • StringNormalizer extensions to support converting line endings of strings for interoperability across OS platforms and compatibility with "on disk" representations.
  • A custom ValidatedNotNullAttribute to allow compiler to assume a parameter value is validated as not null.
  • DictionaryBuilder to enable dictionary initializer style initialization of ImmutableDictionary<TKey, TValue> with significantly reduced overhead.
    • This leverages an ImmutableDictionary<TKey, TValue>.Builder under the hood to build the dictionary. When the ToImmutable() method is called the builder is converted to the immutable state without any overhead of a copy or re-construction of hash tables etc...
  • KvpArrayBuilder to enable initializer style initialization of ImmutableArray<KeyValuePair<TKey, TValue>> with significantly reduced overhead.
    • This leverages an ImmutableArray<T>.Builder under the hood to build the array directly. When the ToImmutable() method is called the builder is converted to the immutable state without any overhead of a copy.
    • Since this is an array and not a dictionary there is no overhead for allocating, initializing or copying any hash mapping for the keys.

Fluent Validation

The library includes extensions that support fluent validation to allow use in property accessors and constructors that forward values to a base or another constructor. This is normally used when the value itself isn't passed on but some transformed value is.

Method Description
ThrowIfNull() Thows an exception if the argument is null or returns it as-is
ThrowIfOutOfRange() Thorws an exception if a value is out of the specified range
ThrowIfNotDefined() Throws an exception if an enum value is undefined

Why not PolyFill?

While it isn't impossible to make polyfill for this to work on .NET standard 2.0 it is a HUGE amount of effort to do so and there's no compelling reason to do so. Roslyn extensions/VSIX extensions are the most likely candidates left. VS extensions are shifting to external processes for extensions for this reason, leaving Roslyn generators. The bottom line is that too much of MODERN .NET and C# is incompatible with .NET Standard 2.0 that a distinct PolyFill library can only cover some of it. (Even the PolySharp generator covers only some of the missing functionality)

Runtime Dependencies

None

There are dependencies on various compile time analyzers but no runtime dependencies are allowed.

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 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 Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework 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 tizen40 was computed.  tizen60 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.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Ubiquity.NET.Extensions:

Package Downloads
Ubiquity.NET.Llvm.Interop

.NET Low Level Interop Bindings for Ubiquity.LibLLVM []. Direct use of this low level API is **STRONGLY** discouraged, instead you should use the Ubiquity.NET.Llvm package, which provides a full C# object model projection of the LLVM APIs on top of this library.

Ubiquity.NET.InteropHelpers

.NET Low Level Interop support library to aid in native code interop scenarios

Ubiquity.NET.Runtime.Utils

General use Support for interpreters/runtimes

Ubiquity.NET.CommandLine

General use Support for Command line parsing based on System.CommandLine

Ubiquity.NET.SrcGeneration

General use Support for Source Generators

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
20.1.8 548 11/17/2025
20.1.8-rc.3 228 11/16/2025
20.1.8-rc.2 166 11/14/2025
20.1.8-rc.1 215 11/13/2025
20.1.8-rc 271 11/2/2025
20.1.8-epsilon 183 10/11/2025
20.1.8-delta 257 9/7/2025
20.1.8-beta 258 9/4/2025
20.1.8-alpha.0.2 536 7/22/2025
20.1.8-alpha.0.1 54 7/18/2025
20.1.8-alpha 165 7/16/2025