Repository navigation
Releases
Releases · Bitvantage/NumericRange
Bitvantage.NumericRange 2.0.0
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 newoperator -does the same for removal. In-place+=and-=change the range directly.|combines two sets;+and+=now only add a single value or aValueRange. Adding two sets with+no longer compiles.==and!=are no longer overloaded onNumericRangeand compare references.Equals,SetEqualsandGetHashCodestill compare values.AddandRemovereturnboolto say whether the set changed.Ranges()returnsValueRangevalues instead of strings, and enumerating aNumericRangeyields its ranges.ParsethrowsFormatExceptioninstead ofArgumentException, accepts whitespace, and rejects empty items and trailing commas.- The package targets net8.0 and net10.0; net7.0 is no longer supported.
New
ValueRangeis a public record struct withStart,End,Count,Contains,OverlapsandDeconstruct.- Set operations named like
ISet<T>:UnionWith,IntersectWith,ExceptWith,SymmetricExceptWith,Overlaps,IsSubsetOf,IsSupersetOf,IsProperSubsetOf,IsProperSupersetOfandSetEquals, plusUnion,Intersect,ExceptandSymmetricExcept, which return a new set. - Operators
|,&,^,-and~for sets, with in-place|=,&=,^=and-=. IsEmpty,RangeCount,ValueCount,Min,Max,ContainsandOverlapsfor a whole range,TryGetRangeandComplement.TryParse, span overloads andISpanParsable<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
Removeof a range that partially overlapped an existing range was a no-op or produced an inverted range.Adddid not merge a range that starts right after the new one, or a preceding range ending atulong.MaxValue.Values()looped forever on a range ending atulong.MaxValue.Add,RemoveandParseaccepted ranges whose end is before the start.Add(this)andRemove(this)threw "Collection was modified".- Null arguments threw
NullReferenceException.