Skip to content

Releases

Bitvantage.NumericRange 2.0.0

Choose a tag to compare

@Bitvantage Bitvantage released this 11 Nov 17:27

Bitvantage.NumericRange 2.0.0 is a major release. The package now targets .NET 8 and .NET 10, is licensed under MIT, and is declared compatible with Native AOT and trimming.

Breaking changes

  • operator + returns a new range instead of changing its left operand. The new operator - does the same for removal. In-place += and -= change the range directly.
  • | combines two sets; + and += now only add a single value or a ValueRange. Adding two sets with + no longer compiles.
  • == and != are no longer overloaded on NumericRange and compare references. Equals, SetEquals and GetHashCode still compare values.
  • Add and Remove return bool to say whether the set changed.
  • Ranges() returns ValueRange values instead of strings, and enumerating a NumericRange yields its ranges.
  • Parse throws FormatException instead of ArgumentException, accepts whitespace, and rejects empty items and trailing commas.
  • The package targets net8.0 and net10.0; net7.0 is no longer supported.

New

  • ValueRange is a public record struct with Start, End, Count, Contains, Overlaps and Deconstruct.
  • Set operations named like ISet<T>: UnionWith, IntersectWith, ExceptWith, SymmetricExceptWith, Overlaps, IsSubsetOf, IsSupersetOf, IsProperSubsetOf, IsProperSupersetOf and SetEquals, plus Union, Intersect, Except and SymmetricExcept, which return a new set.
  • Operators |, &, ^, - and ~ for sets, with in-place |=, &=, ^= and -=.
  • IsEmpty, RangeCount, ValueCount, Min, Max, Contains and Overlaps for a whole range, TryGetRange and Complement.
  • TryParse, span overloads and ISpanParsable<NumericRange>.
  • A JSON converter and a TypeConverter, so a set reads and writes as "80,443" in JSON, configuration files and minimal API parameters.
  • A copy constructor, Clone, collection initializers and collection expressions.
  • XML documentation is generated and shipped in the package.

Fixed

  • Remove of a range that partially overlapped an existing range was a no-op or produced an inverted range.
  • Add did not merge a range that starts right after the new one, or a preceding range ending at ulong.MaxValue.
  • Values() looped forever on a range ending at ulong.MaxValue.
  • Add, Remove and Parse accepted ranges whose end is before the start.
  • Add(this) and Remove(this) threw "Collection was modified".
  • Null arguments threw NullReferenceException.