Cave.Extensions
4.0.10
See the version list below for details.
dotnet add package Cave.Extensions --version 4.0.10
NuGet\Install-Package Cave.Extensions -Version 4.0.10
<PackageReference Include="Cave.Extensions" Version="4.0.10" />
<PackageVersion Include="Cave.Extensions" Version="4.0.10" />
<PackageReference Include="Cave.Extensions" />
paket add Cave.Extensions --version 4.0.10
#r "nuget: Cave.Extensions, 4.0.10"
#:package Cave.Extensions@4.0.10
#addin nuget:?package=Cave.Extensions&version=4.0.10
#tool nuget:?package=Cave.Extensions&version=4.0.10
cave-extensions
A compact .NET library with reusable extensions and helper utilities for everyday development tasks.
Contents
- Supported target platforms
- Static extension classes
- Collections (
Collections/**) - Backports for modern language features on older frameworks
- Unicode, encoding, and hashing
- Progress system (
Progress/**) - Contributing
- License
Supported target platforms
This library is designed to support multiple target platforms, including:
- .NET Framework 2.0
- .NET Framework 3.5
- .NET Framework 4.0
- .NET Framework 4.5
- .NET Framework 4.6
- .NET Framework 4.7
- .NET Framework 4.8
- .NET Standard 2.0
- .NET Standard 2.1
- .NET 8
- .NET 10
Static extension classes
The library includes several static extension types, some of which are conditionally compiled depending on the target framework.
StringExtensions
Comprehensive string and text helpers, including:
- substring operations (
Before*,After*,SubstringEnd) - formatting (
FormatSize,FormatBinarySize,FormatTime,FormatSeconds) - parsing (
ParseDateTime,ParseHexString,ParsePoint,ParseRectangle,ParseSize) - escaping and unescaping (
Escape,EscapeUtf8,Unescape) - case conversion (
GetCamelCaseName,GetPascalCaseName,GetSnakeCaseName,GetKebabCaseName) - split and join extensions (
SplitNewLine,SplitKeepSeparators,Join*) - safe conversion (
ToInt32,ToInt64,ToUInt32,ToBool) - framework-specific backport additions (
*.Backports,*.NetCoreApp1,*.Latest)
TypeExtension
Reflection and conversion helpers for Type:
- universal runtime conversion (
ConvertValue,ConvertPrimitive) - attribute access (
GetAttribute,GetAttributes,HasAttribute) - assembly metadata access (
GetCompanyName,GetProductName) - reflection API backports for older frameworks (
GetMethod,GetProperties,GetProperty,GetFields, ...) - structure checks (
IsStruct)
AssemblyExtension
Extensions for Assembly:
- resolve assembly path and directory
- read product and company names from assembly attributes
- backports for
GetCustomAttributes<T>()on older frameworks
ArrayExtension
Extensions for byte[], arrays, IList<T>, and IEnumerable<T>:
- concatenation and slicing (
Concat,GetRange,SubRange) - pattern and byte processing (
IndexOf,RangeEquals,ReplaceFirst,StartsWith) - reverse iteration
Empty<T>()backport
IListExtension
Extensions for IList<T> and arrays:
- read-only wrapper (
AsReadOnly) - reverse iteration for lists
DictionaryExtensions
Extension for IDictionary<TKey,TValue>:
TryGetValue(..., defaultValue)with fallback value
EnumExtension
Enum helpers, including backports:
- retrieve flags (
GetFlags,GetString) - robust parsing (
Parse,TryParse) HasFlagbackport for older targets
DateTimeExtension
Validation helpers:
IsValidDate(year, month, day)IsValidTime(hours, minutes, seconds)
TimeSpanExtension
Small utility extension:
Absolute()for non-negative time spans
ObjectExtension
Reflection-based object access:
- recursive property enumeration
- property value access by path (
GetPropertyValue,TryGetPropertyValue) - typed property output
- property comparison between objects (
PropertiesEqual)
PropertyInfoExtension
Extensions for PropertyInfo:
IsIndexProperty()- plus a backport file with
GetGetMethod,GetSetMethod,SetValue, andGetValuefor older targets
StreamExtensions
Extensions for Stream:
- block-based copying (
CopyBlocksTo) - full and partial reads (
ReadAllBytes,ReadBlock) - UTF-8 writing (
WriteUtf8) - configurable block size
IPAddressExtension
Networking extensions:
- broadcast and subnet calculation
- reverse lookup zones for IPv4 and IPv6
- multicast detection
- address masking and byte-based manipulation
Backport extension classes (Backports/**)
BackportedExtensionsinSystem.Linq(mainly forNET20): large LINQ backport (Where,Select,GroupBy,Join,Sum,Average,Min/Max, ...)BackportedExtensionsinBackports/StringExtensions.cs: small string backports (StartsWith(char),EndsWith(char))
Collections (Collections/**)
The collections area provides custom data structures for sets, range expressions, and 2D mappings, including read-only and concurrent variants.
Core building blocks
Counter/CountEnumerator
Integer counting ranges asIEnumerable<int>withStart,End,Step,Contains(...), and deterministic iteration.RangeExpression
Parser and model for range strings (for example single values, intervals, step sizes,*).
SupportsParse(...),Contains(...), union (+), and enumeration of all contained values.
Set structures (Collections/Generic)
IItemSet<T>
Unified set API beyondICollection<T>(Include,IncludeRange,TryRemoveRange,IsEmpty).Set<T>
Classic unique set based onHashSet<T>, with set operators:- intersection
& - union
| - difference
- - symmetric difference
^
- intersection
ReadOnlySet<T>
Read-only wrapper aroundIItemSet<T>; all mutating operations throwReadOnlyException.IndexedSet<T>
Set with stable index-based access (IList<T>+ unique values).
CombinesList<T>for ordering and a dictionary index for fast lookups.
2D sets / pair mappings
ItemPair<T1,T2>
Simple pair container (A,B) for associated values.IItemSet<TKey,TValue>
Interface for bidirectional pair structures with access to the A and B dimensions.Set<TKey,TValue>
Unique on the A side, while the B side may contain duplicate values.
Optimized for A-side indexing; B-related operations are intentionally limited.UniqueSet<TKey1,TKey2>
Unique on both sides (A and B), including lookups in both directions (GetA,GetB,TryGetA,TryGetB).ReadOnlyListA<,>/ReadOnlyListB<,>
Read-only views over the A and B side of a 2D set.
Concurrent collections
ConcurrentSet<T>(Collections/Concurrent)
Thread-safe set implementation based onConcurrentDictionary<T, byte>, including the same set operators asSet<T>.
Collection-related backports
Backports/Collections/ObjectModel/ReadOnlyDictionary<TKey,TValue>
Read-only dictionary backport for older targets.LINQ backports (
Backports/Linq/*)
Include supporting collection types such asLookup<TKey,TElement>,Grouping<TKey,TElement>, andOrderedEnumerable<T>for older frameworks.
Backports for modern language features on older frameworks
The Backports/** directory contains targeted backports that make newer C# features and APIs available on older target frameworks.
Backports/Index.cs
Backport ofSystem.Indexfor index access, includingfrom endsemantics (^).Backports/Range.cs
Backport ofSystem.Rangeas the foundation for range expressions such asstart..end.Backports/Runtime/CompilerServices/IsExternalInit.cs
Provides the compiler type required forinitsetters andrecordcompilation on older frameworks.Backports/Linq/BackportedExtensions.cs(#if NET20)
Adds core LINQ functionality for very old platforms, for example:- sequence operators:
Any,All,Cast,OfType,Concat - generation:
Range,Repeat,Empty - processing:
Skip,Take,Reverse,ToArray,ToList - aggregation:
Aggregate,Average,LastOrDefault,ElementAtOrDefault
- sequence operators:
This keeps modern tooling and language constructs broadly compatible, even when the library is deployed on older .NET target platforms.
Unicode, encoding, and hashing
Lightweight IUnicode implementations (interop-friendly without a marshaller)
The library includes lightweight IUnicode types designed for low allocation overhead and direct interop scenarios:
- data is stored in a compact, struct-based representation
- focused on blittable and interop-friendly memory layouts so values can be passed without an additional marshaller
- operates directly on bytes and characters instead of heavyweight object graphs
- suitable for P/Invoke-adjacent paths, protocol parsers, and performance-critical string conversion
Goal: modern Unicode handling on older frameworks with minimal overhead.
Extensions
The extensions complement these types with convenient helpers for Unicode and text-related paths:
- conversion between internal Unicode representations and .NET strings
- simplified processing over sequences and spans, depending on framework support
- consistent APIs for parsing, comparing, and serializing text data
This keeps the low-level types lightweight while still making them ergonomic to use in application code.
BaseX, Base32, Base64
The library provides flexible encoding and decoding for binary data:
BaseXas a general mechanism for alphabet-based encodings- specialized
Base32andBase64implementations for common transport and persistence scenarios - consistent encode/decode APIs, optionally supporting variants depending on the implementation (for example alphabet or padding behavior)
Use cases: reproducible text representations for IDs, tokens, signatures, and binary payloads.
HashCode implementations
For target platforms without modern runtime features, the library provides compatible hash helpers:
- deterministic combination of multiple fields or values into a single hash
- performance-oriented mixing functions for good distribution
- consistent behavior across older and newer frameworks
This simplifies robust GetHashCode() implementations in custom types and reduces platform-specific differences.
Progress system (Progress/**)
The Progress subsystem provides centralized, thread-safe tracking for running processes.
Architecture
IProgress
Unified progress object with:Value(0..1)TextCreated,Identifier,SourceCompleted- event
Updated - methods
Update(...)andComplete()
ProgressItem
Internal concrete implementation ofIProgress.
Behavior:- only monotonic updates are allowed; smaller values are ignored
- values greater than
1are rejected - after
Complete(), further updates are invalid - raises the
Updatedevent when changed or completed
IProgressManager/ProgressManagerBase
Manages active progress instances and centrally forwards their events.
Completed items are automatically removed fromItems.ProgressManager(static facade)
Global entry point:CreateProgress(source)Itemsfor currently running operations- global
Updatedevent - replaceable implementation through
Instance
DefaultProgressManager
Default implementation based onProgressManagerBase.
Event model
- progress events use
Progress/ProgressEventArgswith exactly one payload:Progress(IProgress)
- this ensures every event handler always receives the full state of the corresponding progress object
ETA / estimation system
IEstimation
API for runtime and remaining-time estimation:Elapsed,StartedProgress,ProgressPercentEstimatedCompletionTime,EstimatedTimeLeftUpdate(...),Reset()
Estimation(abstract base)
Stores history points (EstimationItem) and provides:- monotonic progress history
- bounded history (
MaximumItems) Updatedevent withEstimationUpdatedEventArgs
LinearEstimation
Linear ETA calculation based on progress and elapsed time.
For very small progress values, it falls back to a conservative large remaining time.
Summary
The system clearly separates:
- tracking (
IProgress,ProgressItem) - global management and event distribution (
ProgressManager*) - time estimation (
IEstimation,Estimation,LinearEstimation)
This makes it easy to report progress per task, observe it globally, and optionally enrich it with ETA information.
Contributing
Contributions are welcome:
- Create a fork
- Create a feature branch
- Commit your changes
- Open a pull request
License
See LICENSE in the repository.
| 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. 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 is compatible. |
| .NET Framework | net20 is compatible. net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 is compatible. net471 was computed. net472 was computed. net48 is compatible. 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. |
-
.NETFramework 2.0
- No dependencies.
-
.NETFramework 3.5
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.7
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (27)
Showing the top 5 NuGet packages that depend on Cave.Extensions:
| Package | Downloads |
|---|---|
|
Cave.IO
CaveSystems IO Library. This package contains: * Fast non-buffering data readers and writers. * Endian conversion utilities. * FIFO and ring buffer stream implementations. * High‑performance struct marshalling. * INI (settings) readers and writers. * BinarySerializer for lightweight object serialization. * BlobSerializer framework for advanced, version‑resilient binary serialization (reflection-based converters, custom converters, dictionary/enumerable support). |
|
|
Cave.Data
CaveSystems Database Library. Provides simple, fast and typesafe access to ADO.NET based databases. This package supports database first development. |
|
|
Cave.Net
Provides classes for fast and easy access to fast async tcp streaming, dns client, ssl client and server and ntp client and server implementations. |
|
|
Cave.Logging
Provides logging primitives and types for asynchronous, background-dispatched logging. Messages are queued and distributed by a background thread to keep logging fast even when receivers are slow (file, database, network). |
|
|
Cave.Platform
CaveSystems Platform Bibliothek. This packages contains AppDom and Platform detection. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.11-ci-master-20260424-0001 | 88 | 4/24/2026 |
| 4.0.10 | 201 | 4/24/2026 |
| 4.0.9 | 611 | 4/17/2026 |
| 4.0.9-ci-master-20260417-0001 | 86 | 4/17/2026 |
| 4.0.8 | 120 | 2/24/2026 |
| 4.0.8-ci-master-20260224-0001 | 100 | 2/24/2026 |
| 4.0.7 | 122 | 2/17/2026 |
| 4.0.7-ci-master-20260217-0001 | 104 | 2/17/2026 |
| 4.0.6 | 404 | 8/31/2025 |
| 4.0.6-ci-master-20250530-0001 | 233 | 5/30/2025 |
| 4.0.5 | 1,685 | 3/23/2025 |
| 4.0.5-ci-master-20250322-0002 | 261 | 3/22/2025 |
| 4.0.4 | 1,950 | 2/23/2025 |
| 4.0.4-ci-master-20250223-0001 | 174 | 2/23/2025 |
| 4.0.3 | 3,201 | 11/24/2024 |
| 4.0.3-ci-master-20241124-0001 | 177 | 11/24/2024 |
| 4.0.2 | 608 | 10/20/2024 |
| 4.0.2-ci-merge-20241020-0002 | 190 | 10/20/2024 |
| 4.0.2-ci-master-20241020-0003 | 185 | 10/20/2024 |
| 4.0.2-ci-extensions-2024102... | 225 | 10/20/2024 |