Eventualist.Extensions 5.0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Eventualist.Extensions --version 5.0.0.1
                    
NuGet\Install-Package Eventualist.Extensions -Version 5.0.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="Eventualist.Extensions" Version="5.0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Eventualist.Extensions" Version="5.0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Eventualist.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 Eventualist.Extensions --version 5.0.0.1
                    
#r "nuget: Eventualist.Extensions, 5.0.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 Eventualist.Extensions@5.0.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=Eventualist.Extensions&version=5.0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Eventualist.Extensions&version=5.0.0.1
                    
Install as a Cake Tool

Eventualist.Extensions

.NET License: MIT

A collection of lightweight, focused extension methods for common .NET types. Originally created for personal projects but available for anyone to use.

⚠️ Disclaimer

This library is primarily developed for personal use and experimentation. While it is publicly available and contributions are welcome, please note:

  • No Warranty: This software is provided "as is", without warranty of any kind, express or implied
  • Use at Your Own Risk: The library may contain bugs or incomplete features
  • Breaking Changes: API changes may occur between versions without extensive deprecation notices
  • Limited Support: Support and maintenance are provided on a best-effort basis
  • Experimental Features: Some features may be experimental, especially those targeting preview versions of .NET

For production use, please thoroughly test the library in your specific context and consider pinning to a specific version.

Features

Boolean Extensions

  • AddNot(string text, string negation = "not ") - Conditionally prefixes a string with a negation word based on the boolean value
    false.AddNot("implemented") // Returns "not implemented"
    true.AddNot("implemented")  // Returns "implemented"
    
  • ToYesOrNo(string yes = "yes", string no = "no", string unknown = "unknown") - Converts boolean to yes/no strings (supports nullable booleans)
    true.ToYesOrNo()   // Returns "yes"
    false.ToYesOrNo()  // Returns "no"
    ((bool?)null).ToYesOrNo() // Returns "unknown"
    

Collection Extensions

  • IsEmpty<T>() - Returns true if the collection is empty
  • IsNotEmpty<T>() - Returns true if the collection contains any elements
  • Divide<T>(int maxLength) - Splits a collection into sublists with a specified maximum length
    var numbers = new[] { 1, 2, 3, 4, 5, 6, 7 };
    var chunks = numbers.Divide(3); // Returns [[1,2,3], [4,5,6], [7]]
    

String Extensions

  • Titleize() - Converts a string to title case
  • Abbreviate(int maxLength) - Shortens a string to a maximum length with ellipsis
  • Truncate(int maxLength) - Truncates a string to a maximum length
  • StripHtml() - Removes HTML tags from a string
  • HasCorrectExtension(string expectedExtension) - Validates file extension
  • ConvertToMimeType() - Converts file extension to MIME type

DateTime Extensions & Validation

  • MustComeBefore Attribute - Validation attribute to ensure one DateTime property precedes another
    public class TimePeriod
    {
        [MustComeBefore("EndDate")]
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
    }
    

Function Memoization

  • Memoize() - Automatically caches function results for improved performance
    Func<int, int> expensiveOperation = x => { /* ... */ };
    var memoized = expensiveOperation.Memoize();
    // First call computes and caches result
    var result1 = memoized(5);
    // Subsequent calls with same input return cached result
    var result2 = memoized(5); // Instant return from cache
    
    • Supports functions with up to two arguments
    • Note: Not optimized for recursive functions

ExtendedDictionary

  • Thread-safe dictionary implementation with improved performance characteristics

Installation

Add the package reference to your project:

<PackageReference Include="Eventualist.Extensions" Version="4.0.0.3-dev0004" />

Or via the .NET CLI:

dotnet add package Eventualist.Extensions

Compatibility

  • Target Framework: .NET 10.0 (net10.0)
  • C# Language Version: 14.0
  • License: MIT

Version History

  • 4.0.0.3-dev0004: Updated to .NET 10 and C# 14, refreshed CI workflow
  • 3.x: Updates for .NET 9 compatibility
  • 2.0.0.0: .NET 6.0 compatibility (use version 1.0.0.19 for older frameworks)
  • 1.0.0.13: Added Memoize functionality
  • 1.0.0.0: Initial release with Bool and Collection extensions

Building and Testing

The project includes a GitHub Actions CI workflow (.github/workflows/dotnet.yml) that automatically:

  • Restores NuGet packages
  • Builds the solution using .NET 10 SDK
  • Runs all unit tests

Local Development

# Restore dependencies
dotnet restore

# Build the solution
dotnet build

# Run tests
dotnet test

# Create NuGet package
dotnet pack

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Run dotnet test locally to ensure all tests pass
  4. Submit a pull request

Author

Iede Snoek
Email: info@esoxsolutions.nl
Company: Esox Solutions

License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright (c) 2022-2025 Esox Solutions

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.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
5.0.3 31 2/27/2026
5.0.2 433 12/10/2025
5.0.1 423 12/10/2025
5.0.0.1 191 11/15/2025
4.0.0.4 227 6/5/2025
3.0.0.17 369 11/25/2023
3.0.0.9 191 11/25/2023
2.0.0.17 361 3/5/2023
2.0.0.15 411 1/29/2023
2.0.0.11 536 9/3/2022
2.0.0.9 568 7/14/2022
2.0.0.1 566 7/14/2022
1.0.0.19 716 1/4/2021