Wolfgang.Extensions.IEnumerable
1.4.0
Prefix Reserved
dotnet add package Wolfgang.Extensions.IEnumerable --version 1.4.0
NuGet\Install-Package Wolfgang.Extensions.IEnumerable -Version 1.4.0
<PackageReference Include="Wolfgang.Extensions.IEnumerable" Version="1.4.0" />
<PackageVersion Include="Wolfgang.Extensions.IEnumerable" Version="1.4.0" />
<PackageReference Include="Wolfgang.Extensions.IEnumerable" />
paket add Wolfgang.Extensions.IEnumerable --version 1.4.0
#r "nuget: Wolfgang.Extensions.IEnumerable, 1.4.0"
#:package Wolfgang.Extensions.IEnumerable@1.4.0
#addin nuget:?package=Wolfgang.Extensions.IEnumerable&version=1.4.0
#tool nuget:?package=Wolfgang.Extensions.IEnumerable&version=1.4.0
Wolfgang.Extensions.IEnumerable
A collection of extension methods for IEnumerable<T> in .NET.
📦 Installation
dotnet add package Wolfgang.Extensions.IEnumerable
NuGet Package: Wolfgang.Extensions.IEnumerable
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
📚 Documentation
- GitHub Repository: https://github.com/Chris-Wolfgang/IEnumerable-Extensions
- API Documentation: https://Chris-Wolfgang.github.io/IEnumerable-Extensions/
- CHANGELOG: CHANGELOG.md
- Contributing Guide: CONTRIBUTING.md
🚀 Quick Start
using System.Collections.Generic;
using System.Linq;
using Wolfgang.Extensions.IEnumerable;
var items = new[] { 1, 2, 3, 4, 5 };
items.ForEach(Console.WriteLine); // prints 1..5 (eager)
var doubled = items
.Do(x => Console.WriteLine($"seen: {x}")) // lazy passthrough side-effect
.Select(x => x * 2)
.ToList();
items.IsEmpty(); // false
((int[]?)null).IsNullOrEmpty(); // true (only IsNullOrEmpty accepts null)
items.None(x => x > 10); // true
items.None(); // false (has items)
var shuffled = items.Shuffle().ToList(); // random order (Fisher-Yates)
None of these methods mutate the source sequence — ForEach and Do invoke
your Action<T> for its side effects but never modify the upstream items
themselves. Only IsNullOrEmpty accepts a null source (returns true); every
other method throws ArgumentNullException when source is null. Methods
that take an action / predicate also throw on a null callback.
✨ Features
Methods
| Method | Description |
|---|---|
ForEach(Action<T>) |
Eagerly invokes an action for each item. Throws ArgumentNullException if source or action is null. |
Do(Action<T>) |
Lazy variant of ForEach — yields each item after invoking the action. |
IsEmpty() |
Returns true when the sequence contains no elements. |
IsNullOrEmpty() |
Returns true when the sequence is null OR contains no elements. |
None() |
Inverse of Any() — true when the sequence has no elements. |
None(Func<T, bool> predicate) |
true when no element matches the predicate. |
Shuffle() |
Returns a new sequence in random order (Fisher-Yates + thread-safe RNG). Eager — the input is fully consumed before the method returns. |
ToEnumerable() |
Wraps the source in a lazy iterator so the returned sequence is guaranteed not to be a more concrete type (List<T>, ICollection<T>, array). Useful in tests that need to exercise non-ICollection code paths. |
Examples
using System.Collections.Generic;
using System.Linq;
using Wolfgang.Extensions.IEnumerable;
// ForEach vs Do
new[] { 1, 2, 3 }.ForEach(Console.WriteLine); // 1 2 3 (eager, void)
var pipeline = new[] { 1, 2, 3 }
.Do(x => Console.WriteLine($"tap: {x}")) // lazy passthrough
.Where(x => x > 1); // logs only when enumerated
// Emptiness
new int[0].IsEmpty(); // true
((IEnumerable<int>?)null).IsNullOrEmpty(); // true (null-tolerant)
// ((IEnumerable<int>?)null).IsEmpty(); // throws ArgumentNullException
// None
new[] { 1, 2, 3 }.None(); // false
new[] { 1, 2, 3 }.None(x => x < 0); // true
// Shuffle
var deck = Enumerable.Range(1, 52).Shuffle().ToList();
// ToEnumerable — strip the concrete type for test fixtures that need to
// exercise the non-ICollection slow path.
IEnumerable<int> slowPath = new List<int> { 1, 2, 3 }.ToEnumerable();
// slowPath is List<int> // false
// slowPath is ICollection<int> // false
🎯 Target Frameworks
| Framework | Versions |
|---|---|
| .NET Framework | .NET 4.6.2 |
| .NET Standard | .NET Standard 2.0 |
| .NET | .NET 8.0, .NET 10.0 |
🛠️ Building from Source
Prerequisites
- .NET 10.0 SDK
- Optional: PowerShell Core for formatting scripts
Build Steps
git clone https://github.com/Chris-Wolfgang/IEnumerable-Extensions.git
cd IEnumerable-Extensions
dotnet restore
dotnet build --configuration Release
dotnet test --configuration Release
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for code quality standards, build and test instructions, and pull request guidelines.
| 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 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. |
| .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 is compatible. 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. |
-
.NETFramework 4.6.2
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net10.0
- 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.