DotNetXtensions.Mini
1.0.0
dotnet add package DotNetXtensions.Mini --version 1.0.0
NuGet\Install-Package DotNetXtensions.Mini -Version 1.0.0
<PackageReference Include="DotNetXtensions.Mini" Version="1.0.0" />
<PackageVersion Include="DotNetXtensions.Mini" Version="1.0.0" />
<PackageReference Include="DotNetXtensions.Mini" />
paket add DotNetXtensions.Mini --version 1.0.0
#r "nuget: DotNetXtensions.Mini, 1.0.0"
#:package DotNetXtensions.Mini@1.0.0
#addin nuget:?package=DotNetXtensions.Mini&version=1.0.0
#tool nuget:?package=DotNetXtensions.Mini&version=1.0.0
DotNetXtensions.Mini
A lightweight, streamlined version of DotNetXtensions containing the most commonly used extension methods and utilities for .NET development. This mini version provides essential string, collection, character, date/time, and path manipulation utilities without the full library overhead. It is also possible to use the single file DotNetXtensions.Mini.cs directly in your project without needing to reference the NuGet package.
Installation
Add the NuGet package to your project:
dotnet add package DotNetXtensions.Mini
Features
String Extensions
Unfortunately, EVEN in 2026 (!), .NET still lacks extension methods for extremely common string operations, the most famous of all: IsNullOrEmpty. Now perhaps the most controversial naming decision on my part is embracing in this almost singular case, an abbreviated name: IsNulle() and NotNulle(). If that bugs you, I hope you can forgive it! Feel free to use the non-abbreviated version: IsNullOrEmpty().
Null/Empty Checks
IsNulle()- 🌟 Checks if string is null or empty (faster than built-in methods) 🌟NotNulle()- 🌟 Checks if string is NOT null or empty 🌟IsNullOrEmpty()- 🌟 Alias for standard null/empty check 🌟IsNullOrWhiteSpace()- Extension wrapper forstring.IsNullOrWhiteSpaceNullIfEmpty()- 🌟 Returns null if string is empty, otherwise returns the string 🌟
string str = "";
if (str.IsNulle()) // true
WriteLine("Empty or null");
string name = "John";
if (name.NotNulle()) // true
WriteLine($"Hello {name}");
String Trimming
TrimIfNeeded()- Only trims if whitespace exists at start/end. More efficient, returns the same string when not.IsTrimmable()- Checks if string has leading/trailing whitespaceTrimN()- Trims if not null, returns null otherwise.NullIfEmptyTrimmed()- 🌟 Trims and returns null if result is empty. This is another STAR that appears prolifically. 🌟
string text = " hello ";
string trimmed = text.TrimIfNeeded(); // "hello"
string text2 = "hello";
bool needsTrim = text2.IsTrimmable(); // false (no trimming needed)
String Utilities
ContainsIgnoreCase()- Case-insensitive contains checkLengthN()/CountN()- Returns length or default value if null
string str = "Hello World";
bool contains = str.ContainsIgnoreCase("WORLD"); // true
string nullStr = null;
int length = nullStr.LengthN(-1); // -1 (default value)
Collection Extensions
Null/Empty Checks
IsNulle()- 🌟🌟 Checks if collection/array is null or empty 🌟🌟NotNulle()- 🌟🌟 Checks if collection has items 🌟🌟
List<int> numbers = new();
if (numbers.IsNulle()) // true
WriteLine("No numbers");
int[] items = { 1, 2, 3 };
if (items.NotNulle()) // true
WriteLine($"Has {items.Length} items");
Collection Utilities
CountN()/LengthN()- Returns count/length or default value if nullJoinToString()- Joins collection elements into string with separator 🌟
List<int> numbers = null;
int count = numbers.CountN(); // 0
var names = new[] { "Alice", "Bob", "Charlie" };
string joined = names.JoinToString(); // "Alice,Bob,Charlie"
var users = new[] { new User("Alice"), new User("Bob") };
string userNames = users.JoinToString(u => u.Name, "; "); // "Alice; Bob"
Character Extensions
ASCII Checks
High-performance character checks for ASCII characters:
IsAsciiDigit()- Checks for 0-9IsAsciiLetter()- Checks for a-z or A-ZIsAsciiLower()- Checks for a-zIsAsciiUpper()- Checks for A-ZIsAsciiLetterOrDigit()- Checks for a-z, A-Z, or 0-9IsAsciiLowerOrDigit()- Checks for a-z or 0-9IsAsciiUpperOrDigit()- Checks for A-Z or 0-9
char c = '5';
if (c.IsAsciiDigit()) // true
WriteLine("It's a digit");
char letter = 'a';
if (letter.IsAsciiLower()) // true
WriteLine("Lowercase letter");
Character Utilities
IsWhitespace()- Extension wrapper forchar.IsWhiteSpaceIsUpper()/IsLower()- Extension wrappers for case checksIsNumber()- Extension wrapper forchar.IsNumberToInt()- Converts digit character to integer (e.g., '5' → 5) 🌟
char digit = '7';
int num = digit.ToInt(); // 7
Numeric Extensions
Range Checks
Generic range checking for numeric types:
InRange()- Checks if value is within range (inclusive) 🌟NotInRange()- Checks if value is outside range 🌟
int age = 25;
if (age.InRange(18, 65)) // true
WriteLine("Working age");
double temp = 15.5;
if (temp.NotInRange(20.0, 30.0)) // true
WriteLine("Outside comfort zone");
string name = "John";
if (name.InRange(1, 50)) // true (checks length)
WriteLine("Valid name length");
DateTime Extensions
Rounding Methods
Round DateTime and DateTimeOffset to nearest intervals:
Round()- Rounds to nearest intervalRoundUp()- Always rounds up to next intervalRoundDown()- Always rounds down to previous intervalRoundToNearest()- Rounds to nearest interval
DateTime dt = new DateTime(2024, 1, 15, 10, 37, 0);
// Round to nearest 15 minutes
DateTime rounded = dt.Round(TimeSpan.FromMinutes(15)); // 10:30:00
// Round up to next hour
DateTime roundedUp = dt.RoundUp(TimeSpan.FromHours(1)); // 11:00:00
// Round down to previous hour
DateTime roundedDown = dt.RoundDown(TimeSpan.FromHours(1)); // 10:00:00
// Works with DateTimeOffset too
DateTimeOffset dto = DateTimeOffset.Now;
DateTimeOffset rounded2 = dto.RoundToNearest(TimeSpan.FromMinutes(5));
Dictionary Extensions
Comparison
DictionariesAreEqual()- Deep equality comparison of dictionaries
var dict1 = new Dictionary<string, int> { ["a"] = 1, ["b"] = 2 };
var dict2 = new Dictionary<string, int> { ["a"] = 1, ["b"] = 2 };
bool equal = dict1.DictionariesAreEqual(dict2); // true
// With custom comparer
var dict3 = new Dictionary<string, User> { ["alice"] = new User("Alice", 25) };
var dict4 = new Dictionary<string, User> { ["alice"] = new User("Alice", 25) };
bool equal2 = dict3.DictionariesAreEqual(dict4, (u1, u2) => u1.Name == u2.Name);
Path Utilities (PathX)
TO INCLUDE or NOT to include... that is the question
Not sure if we will include this. I do however very frequently find myself needing this type of path manipulations.
Clean path manipulation that handles nulls gracefully and normalizes paths:
- 🌟🌟 All paths are automatically converted to use forward slashes (
/) instead of backslashes. 🌟🌟 (throughout all the following) CleanPath()- Normalizes path to use forward slashes and trimsGetFullPath()- Gets full path with null handling and cleaningGetDirectoryName()- Gets directory name with null handling and cleaningPathCombine()- Combines paths with cleaning
string path = PathX.CleanPath(@"C:\Users\Documents\");
// Result: "C:/Users/Documents"
string fullPath = PathX.GetFullPath("./file.txt");
// Gets full path and cleans it
string combined = PathX.PathCombine("folder", "subfolder/file.txt");
// Result: "folder/subfolder/file.txt"
Console Output
Print()- 🌟🌟 Quick console output for strings and objects 🌟🌟
"Hello World".Print(); // Outputs to console and returns the string
var obj = new { Name = "Test", Value = 42 };
obj.Print(); // Outputs object to console
Performance Features
Many methods in this library are optimized for performance:
[MethodImpl(MethodImplOptions.AggressiveInlining)]for hot-path methods. This is key, especially for the string and character methods that are called frequently.- ASCII character methods use direct numeric comparisons instead of slower .NET methods
TrimIfNeeded()checks before allocating new strings
Target Framework
- .NET 8.0
License
MIT
Relationship to DotNetXtensions
This is a mini version of the older, but more comprehensive DotNetXtensions library. I have found over the years, that for many projects, I only need a subset of the full library's features. Also that one maybe bloated on some parts, I'm striving to keep this lean. Still keeping this 'alpha' while we work out the best set of methods to include (early 2026)
Contributing
Issues and pull requests are welcome at the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DotNetXtensions.Mini:
| Package | Downloads |
|---|---|
|
HtmlTag
A high-performance, single-pass, zero-allocation HTML opening tag parser for .NET 8+ |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 43 | 2/25/2026 |
| 1.0.0-alpha-3.0 | 47 | 2/20/2026 |
| 1.0.0-alpha-2.0 | 227 | 12/3/2025 |
| 1.0.0-alpha-1.0 | 224 | 11/27/2025 |