-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
dotnet/coreclr
#24612Labels
area-System.MemorydocumentationDocumentation bug or enhancement, does not impact product or test codeDocumentation bug or enhancement, does not impact product or test codehelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
From MS Docs page on Span<T>.Slice(int) method: ArgumentOutOfRangeException is thrown if index(probably start?) is less than zero or greater than or equal to Length.
However, span.Slice(span.Length) does not seem to throw; The example code below executes with no problem.
"asd".ToCharArray().AsSpan().Slice(3)It appears to be an incorrect document rather than a problem with the implementation, as the documentation for ReadOnlySpan<T>.Slice(int) says that ArgumentOutOfRangeException is thrown if start is greater than the number of items in the read-only span.
Is this behaviour expected? I also have found that XML documentations on these methods (Span.Slice, ReadOnlySpan.Slice) says so as well.
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown when the specified <paramref name="start"/> or end index is not in range (<0 or >=Length).
/// </exception><0 or >=Length seems to imply that it should throw if I pass Length as the parameter.
Metadata
Metadata
Assignees
Labels
area-System.MemorydocumentationDocumentation bug or enhancement, does not impact product or test codeDocumentation bug or enhancement, does not impact product or test codehelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors