Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofCwalina committed Dec 15, 2017
1 parent 48f5e45 commit 7a01e8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/System.Buffers.Experimental/System/Range.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void Deconstruct(out int first, out int end)
first = First;
end = End;
}

public static Range Construct(int first, int end)
=> new Range(first, end);

Expand Down Expand Up @@ -97,7 +98,7 @@ public bool Contains(int value)
}

/// <summary>
/// Returns true if this Range is a valid range for a zero based index of sspecified length.
/// Returns true if this Range is a valid range for a zero based index of specified length.
/// </summary>
/// <param name="length">zero based length.</param>
/// <returns></returns>
Expand All @@ -115,10 +116,14 @@ public bool IsValid(int length)
if (First > length) return false;
return End <= length;
}

throw new NotImplementedException();
}

/// <summary>
/// Converts an unbound Range (IsBound == false) to a bound one (IsBound == true).
/// </summary>
/// <param name="length">zero based length of an indexable 'list' the range is being bound to.</param>
/// <returns>Bound Range (IsBound == true).</returns>
/// <remarks>The method throws ArgumentOutOfRangeException Range.IsValid(lenght) returns false.</remarks>
public Range Bind(int length)
{
if (!IsValid(length)) throw new ArgumentOutOfRangeException(nameof(length));
Expand Down
2 changes: 1 addition & 1 deletion tests/System.Buffers.Experimental.Tests/RangeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void Errors()
});
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
// MaxValue is used as a sentinel for End, so End cannot endup being it.
// MaxValue is used as a sentinel for End, so End cannot end up being it.
var tooLong = new Range(int.MaxValue, 1);
});
Assert.Throws<InvalidOperationException>(() =>
Expand Down

0 comments on commit 7a01e8e

Please sign in to comment.