.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
The indexer function Span2D<T>.Item[Range row, Range column] is similar to Span<T>.Item[Range range]. However, the latter returns an empty span when range's Start and End both equal the length of the span. The same is not true for the former's row and column arguments.
Regression
Not a regression
Steps to reproduce
These lines of code cause an ArgumentOutOfRangeException to be thrown:
var cornerOfEmptySpan2d = Span2D<int>.Empty[0..0,0..0];
var cornerOfSingleItemSpan2d = (new Span2D<int>(new[,] {{0}}))[1..1,1..1];
Whereas these do not:
var endOfEmptySpan = Span<int>.Empty[0..0];
var endOfSingleItemSpan = (new Span<int>(new[] {0}))[1..1];
Expected behavior
Span2D<int>.Empty[0..0,0..0] and (new Span2D<int>(new[,] {{0}}))[1..1,1..1] should return an empty Span2D.
Describe the bug
The indexer function
Span2D<T>.Item[Range row, Range column]
is similar toSpan<T>.Item[Range range]
. However, the latter returns an empty span whenrange
'sStart
andEnd
both equal the length of the span. The same is not true for the former'srow
andcolumn
arguments.Regression
Not a regression
Steps to reproduce
These lines of code cause an
ArgumentOutOfRangeException
to be thrown:Whereas these do not:
Expected behavior
Span2D<int>.Empty[0..0,0..0]
and(new Span2D<int>(new[,] {{0}}))[1..1,1..1]
should return an empty Span2D.Screenshots
No response
IDE and version
VS 2019
IDE version
No response
Nuget packages
Nuget package version(s)
8.1.0
Additional context
No response
Help us help you
No, just wanted to report this