You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update Enumerable.Sequence based on post-merge feedback (#116793)
* Update Enumerable.Sequence based on post-merge feedback
- Use T.IsPositive/IsZero
- Put zero check first
- Throw for NaN
- Rename a parameter to clarify its purpose
- Add some comments
* Add exception docs
Copy file name to clipboardExpand all lines: src/libraries/System.Linq.AsyncEnumerable/src/System/Linq/Sequence.cs
+45-27Lines changed: 45 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,18 @@ namespace System.Linq
11
11
{
12
12
publicstaticpartialclassAsyncEnumerable
13
13
{
14
-
/// <summary>Generates a sequence that begins with <paramref name="start"/> and yields additional values each incremented by <paramref name="step"/> until <paramref name="endInclusive"/> is reached.</summary>
14
+
/// <summary>Generates a sequence that begins with <paramref name="start"/> and yields additional values each incremented by <paramref name="step"/> until <paramref name="endInclusive"/> is reached.</summary>
15
15
/// <typeparam name="T">The type of the value to be yielded in the result sequence.</typeparam>
16
16
/// <param name="start">The starting value. This value will always be included in the resulting sequence.</param>
17
17
/// <param name="endInclusive">The ending bound beyond which values will not be included in the sequence.</param>
18
18
/// <param name="step">The amount by which the next value in the sequence should be incremented from the previous value.</param>
19
19
/// <returns>An <see cref="IAsyncEnumerable{T}"/> that contains the sequence.</returns>
20
20
/// <exception cref="ArgumentNullException"><paramref name="start"/> is <see langword="null"/>.</exception>
21
-
/// <exception cref="ArgumentNullException"><paramref name="step"/> is <see langword="null"/>.</exception>
22
21
/// <exception cref="ArgumentNullException"><paramref name="endInclusive"/> is <see langword="null"/>.</exception>
22
+
/// <exception cref="ArgumentNullException"><paramref name="step"/> is <see langword="null"/>.</exception>
23
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="start"/> is NaN.</exception>
24
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="endInclusive"/> is NaN.</exception>
25
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="step"/> is NaN.</exception>
23
26
/// <exception cref="ArgumentOutOfRangeException"><paramref name="step"/> is greater than zero but <paramref name="endInclusive"/> is less than <paramref name="start"/>.</exception>
24
27
/// <exception cref="ArgumentOutOfRangeException"><paramref name="step"/> is less than zero but <paramref name="endInclusive"/> is greater than <paramref name="start"/>.</exception>
25
28
/// <exception cref="ArgumentOutOfRangeException"><paramref name="step"/> is zero and <paramref name="endInclusive"/> does not equal <paramref name="start"/>.</exception>
@@ -30,17 +33,43 @@ public static IAsyncEnumerable<T> Sequence<T>(T start, T endInclusive, T step) w
Copy file name to clipboardExpand all lines: src/libraries/System.Linq/src/System/Linq/Sequence.cs
+45-27Lines changed: 45 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,18 @@ namespace System.Linq
11
11
{
12
12
publicstaticpartialclassEnumerable
13
13
{
14
-
/// <summary>Generates a sequence that begins with <paramref name="start"/> and yields additional values each incremented by <paramref name="step"/> until <paramref name="endInclusive"/> is reached.</summary>
14
+
/// <summary>Generates a sequence that begins with <paramref name="start"/> and yields additional values each incremented by <paramref name="step"/> until <paramref name="endInclusive"/> is reached.</summary>
15
15
/// <typeparam name="T">The type of the value to be yielded in the result sequence.</typeparam>
16
16
/// <param name="start">The starting value. This value will always be included in the resulting sequence.</param>
17
17
/// <param name="endInclusive">The ending bound beyond which values will not be included in the sequence.</param>
18
18
/// <param name="step">The amount by which the next value in the sequence should be incremented from the previous value.</param>
19
19
/// <returns>An <see cref="IEnumerable{T}"/> that contains the sequence.</returns>
20
20
/// <exception cref="ArgumentNullException"><paramref name="start"/> is <see langword="null"/>.</exception>
21
-
/// <exception cref="ArgumentNullException"><paramref name="step"/> is <see langword="null"/>.</exception>
22
21
/// <exception cref="ArgumentNullException"><paramref name="endInclusive"/> is <see langword="null"/>.</exception>
22
+
/// <exception cref="ArgumentNullException"><paramref name="step"/> is <see langword="null"/>.</exception>
23
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="start"/> is NaN.</exception>
24
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="endInclusive"/> is NaN.</exception>
25
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="step"/> is NaN.</exception>
23
26
/// <exception cref="ArgumentOutOfRangeException"><paramref name="step"/> is greater than zero but <paramref name="endInclusive"/> is less than <paramref name="start"/>.</exception>
24
27
/// <exception cref="ArgumentOutOfRangeException"><paramref name="step"/> is less than zero but <paramref name="endInclusive"/> is greater than <paramref name="start"/>.</exception>
25
28
/// <exception cref="ArgumentOutOfRangeException"><paramref name="step"/> is zero and <paramref name="endInclusive"/> does not equal <paramref name="start"/>.</exception>
@@ -30,17 +33,43 @@ public static IEnumerable<T> Sequence<T>(T start, T endInclusive, T step) where
0 commit comments