Skip to content

v1.3.0

Compare
Choose a tag to compare
@JeevanJames JeevanJames released this 17 Jan 08:18
· 75 commits to master since this release

Change log

  • ForEach methods now return the original collection to allow for fluent syntax.

  • The AddRange overload that accepts a predicate and a converter takes an additional parameter - a predicate that works on the converted data. The first predicate parameter works on the data before it is converted.

var list = new List<int> {1, 2, 3};
var dataToAdd = new[] {"7", "8", "9", "10", "11", "12"};
list.Add(dataToAdd,
    s => s.Length == 1,    // Predicate on string - only strings of length 1
    s => int.Parse,        // Converter - converts string to int
    n => n % 2 == 0);      // Predicate on int - only even numbers
  • Added InsertRange extension methods on IList<T> that inserts one or more items to a collection at a specific location.

Low impact breaking changes

  • Moved methods from CollectionExtensions class to other classes based on the interface they are extending. So, methods that extend IEnumerable<T> are moved to EnumerableExtensions and methods that extend IList<T> are moved to ListExtensions. Methods that extend ICollection<T> remain in the same class.

    This is only a breaking change if you call these methods as static methods instead of as extension methods.

int[] array = new int[10];

// Calling as a static method - This will break
CollectionExtensions.Fill(array, 7);

// Calling as an extension method - This will not break
array.Fill(7);