Skip to content

Commit 47f253f

Browse files
OracePierre LANDO
authored andcommitted
Update Zip* comments.
Added missing ArgumentNullException. Use ordinal in for type parameter names.
1 parent 9ec453e commit 47f253f

File tree

8 files changed

+475
-431
lines changed

8 files changed

+475
-431
lines changed

MoreLinq/EquiZip.g.cs

Lines changed: 66 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,34 @@ static partial class MoreEnumerable
2424
{
2525
/// <summary>
2626
/// <para>
27-
/// Returns a sequence of projections, each projection is build from two elements.
28-
/// For the N-th projection, these two elements are those located
29-
/// at the N-th position of the two input sequences.</para>
27+
/// Applies a specified function to the corresponding elements of two sequences,
28+
/// producing a sequence of the results.</para>
3029
/// <para>
3130
/// The resulting sequence has the same length as the input sequences.
3231
/// If the input sequences are of different lengths, an exception is thrown.</para>
3332
/// </summary>
34-
/// <typeparam name="T1">Type of elements in the first input sequence.</typeparam>
35-
/// <typeparam name="T2">Type of elements in the second input sequence.</typeparam>
36-
/// <typeparam name="TResult">Type of elements in the returned sequence.</typeparam>
37-
/// <param name="first">The first source sequence.</param>
38-
/// <param name="second">The second source sequence.</param>
33+
/// <typeparam name="TFirst">The type of the elements of the first input sequence.</typeparam>
34+
/// <typeparam name="TSecond">The type of the elements of the second input sequence.</typeparam>
35+
/// <typeparam name="TResult">The type of the elements of the result sequence.</typeparam>
36+
/// <param name="first">The first sequence to merge.</param>
37+
/// <param name="second">The second sequence to merge.</param>
3938
/// <param name="resultSelector">
40-
/// The function that make projections of two elements.</param>
39+
/// A function that specifies how to merge the elements from the two sequences.</param>
4140
/// <returns>
42-
/// A sequence of projections built from two elements,
43-
/// each element coming from one of the two input sequences.</returns>
41+
/// An <code>IEnumerable</code> that contains merged elements of two input sequences.</returns>
42+
/// <exception cref="ArgumentNullException">
43+
/// <paramref name="first"/>,
44+
/// <paramref name="second"/> or
45+
/// <paramref name="resultSelector"/> is <code>null</code>.</exception>
4446
/// <exception cref="InvalidOperationException">
4547
/// The input sequences are of different lengths.</exception>
4648
/// <remarks>
4749
/// This operator uses deferred execution and streams its results.</remarks>
4850

49-
public static IEnumerable<TResult> EquiZip<T1, T2, TResult>(
50-
this IEnumerable<T1> first,
51-
IEnumerable<T2> second,
52-
Func<T1, T2, TResult> resultSelector)
51+
public static IEnumerable<TResult> EquiZip<TFirst, TSecond, TResult>(
52+
this IEnumerable<TFirst> first,
53+
IEnumerable<TSecond> second,
54+
Func<TFirst, TSecond, TResult> resultSelector)
5355
{
5456
if (first == null) throw new ArgumentNullException(nameof(first));
5557
if (second == null) throw new ArgumentNullException(nameof(second));
@@ -78,41 +80,44 @@ public static IEnumerable<TResult> EquiZip<T1, T2, TResult>(
7880
}
7981
}
8082

81-
throw new InvalidOperationException("Sequences differ in length.");
83+
throw new InvalidOperationException("The input sequences are of different lengths.");
8284
}
8385
}
8486

8587
/// <summary>
8688
/// <para>
87-
/// Returns a sequence of projections, each projection is build from three elements.
88-
/// For the N-th projection, these three elements are those located
89-
/// at the N-th position of the three input sequences.</para>
89+
/// Applies a specified function to the corresponding elements of three sequences,
90+
/// producing a sequence of the results.</para>
9091
/// <para>
9192
/// The resulting sequence has the same length as the input sequences.
9293
/// If the input sequences are of different lengths, an exception is thrown.</para>
9394
/// </summary>
94-
/// <typeparam name="T1">Type of elements in the first input sequence.</typeparam>
95-
/// <typeparam name="T2">Type of elements in the second input sequence.</typeparam>
96-
/// <typeparam name="T3">Type of elements in the third input sequence.</typeparam>
97-
/// <typeparam name="TResult">Type of elements in the returned sequence.</typeparam>
98-
/// <param name="first">The first source sequence.</param>
99-
/// <param name="second">The second source sequence.</param>
100-
/// <param name="third">The third source sequence.</param>
95+
/// <typeparam name="TFirst">The type of the elements of the first input sequence.</typeparam>
96+
/// <typeparam name="TSecond">The type of the elements of the second input sequence.</typeparam>
97+
/// <typeparam name="TThird">The type of the elements of the third input sequence.</typeparam>
98+
/// <typeparam name="TResult">The type of the elements of the result sequence.</typeparam>
99+
/// <param name="first">The first sequence to merge.</param>
100+
/// <param name="second">The second sequence to merge.</param>
101+
/// <param name="third">The third sequence to merge.</param>
101102
/// <param name="resultSelector">
102-
/// The function that make projections of three elements.</param>
103+
/// A function that specifies how to merge the elements from the three sequences.</param>
103104
/// <returns>
104-
/// A sequence of projections built from three elements,
105-
/// each element coming from one of the three input sequences.</returns>
105+
/// An <code>IEnumerable</code> that contains merged elements of three input sequences.</returns>
106+
/// <exception cref="ArgumentNullException">
107+
/// <paramref name="first"/>,
108+
/// <paramref name="second"/>,
109+
/// <paramref name="third"/> or
110+
/// <paramref name="resultSelector"/> is <code>null</code>.</exception>
106111
/// <exception cref="InvalidOperationException">
107112
/// The input sequences are of different lengths.</exception>
108113
/// <remarks>
109114
/// This operator uses deferred execution and streams its results.</remarks>
110115

111-
public static IEnumerable<TResult> EquiZip<T1, T2, T3, TResult>(
112-
this IEnumerable<T1> first,
113-
IEnumerable<T2> second,
114-
IEnumerable<T3> third,
115-
Func<T1, T2, T3, TResult> resultSelector)
116+
public static IEnumerable<TResult> EquiZip<TFirst, TSecond, TThird, TResult>(
117+
this IEnumerable<TFirst> first,
118+
IEnumerable<TSecond> second,
119+
IEnumerable<TThird> third,
120+
Func<TFirst, TSecond, TThird, TResult> resultSelector)
116121
{
117122
if (first == null) throw new ArgumentNullException(nameof(first));
118123
if (second == null) throw new ArgumentNullException(nameof(second));
@@ -143,44 +148,48 @@ public static IEnumerable<TResult> EquiZip<T1, T2, T3, TResult>(
143148
}
144149
}
145150

146-
throw new InvalidOperationException("Sequences differ in length.");
151+
throw new InvalidOperationException("The input sequences are of different lengths.");
147152
}
148153
}
149154

150155
/// <summary>
151156
/// <para>
152-
/// Returns a sequence of projections, each projection is build from four elements.
153-
/// For the N-th projection, these four elements are those located
154-
/// at the N-th position of the four input sequences.</para>
157+
/// Applies a specified function to the corresponding elements of four sequences,
158+
/// producing a sequence of the results.</para>
155159
/// <para>
156160
/// The resulting sequence has the same length as the input sequences.
157161
/// If the input sequences are of different lengths, an exception is thrown.</para>
158162
/// </summary>
159-
/// <typeparam name="T1">Type of elements in the first input sequence.</typeparam>
160-
/// <typeparam name="T2">Type of elements in the second input sequence.</typeparam>
161-
/// <typeparam name="T3">Type of elements in the third input sequence.</typeparam>
162-
/// <typeparam name="T4">Type of elements in the fourth input sequence.</typeparam>
163-
/// <typeparam name="TResult">Type of elements in the returned sequence.</typeparam>
164-
/// <param name="first">The first source sequence.</param>
165-
/// <param name="second">The second source sequence.</param>
166-
/// <param name="third">The third source sequence.</param>
167-
/// <param name="fourth">The fourth source sequence.</param>
163+
/// <typeparam name="TFirst">The type of the elements of the first input sequence.</typeparam>
164+
/// <typeparam name="TSecond">The type of the elements of the second input sequence.</typeparam>
165+
/// <typeparam name="TThird">The type of the elements of the third input sequence.</typeparam>
166+
/// <typeparam name="TFourth">The type of the elements of the fourth input sequence.</typeparam>
167+
/// <typeparam name="TResult">The type of the elements of the result sequence.</typeparam>
168+
/// <param name="first">The first sequence to merge.</param>
169+
/// <param name="second">The second sequence to merge.</param>
170+
/// <param name="third">The third sequence to merge.</param>
171+
/// <param name="fourth">The fourth sequence to merge.</param>
168172
/// <param name="resultSelector">
169-
/// The function that make projections of four elements.</param>
173+
/// A function that specifies how to merge the elements from the four sequences.</param>
170174
/// <returns>
171-
/// A sequence of projections built from four elements,
172-
/// each element coming from one of the four input sequences.</returns>
175+
/// An <code>IEnumerable</code> that contains merged elements of four input sequences.</returns>
176+
/// <exception cref="ArgumentNullException">
177+
/// <paramref name="first"/>,
178+
/// <paramref name="second"/>,
179+
/// <paramref name="third"/>,
180+
/// <paramref name="fourth"/> or
181+
/// <paramref name="resultSelector"/> is <code>null</code>.</exception>
173182
/// <exception cref="InvalidOperationException">
174183
/// The input sequences are of different lengths.</exception>
175184
/// <remarks>
176185
/// This operator uses deferred execution and streams its results.</remarks>
177186

178-
public static IEnumerable<TResult> EquiZip<T1, T2, T3, T4, TResult>(
179-
this IEnumerable<T1> first,
180-
IEnumerable<T2> second,
181-
IEnumerable<T3> third,
182-
IEnumerable<T4> fourth,
183-
Func<T1, T2, T3, T4, TResult> resultSelector)
187+
public static IEnumerable<TResult> EquiZip<TFirst, TSecond, TThird, TFourth, TResult>(
188+
this IEnumerable<TFirst> first,
189+
IEnumerable<TSecond> second,
190+
IEnumerable<TThird> third,
191+
IEnumerable<TFourth> fourth,
192+
Func<TFirst, TSecond, TThird, TFourth, TResult> resultSelector)
184193
{
185194
if (first == null) throw new ArgumentNullException(nameof(first));
186195
if (second == null) throw new ArgumentNullException(nameof(second));
@@ -213,7 +222,7 @@ public static IEnumerable<TResult> EquiZip<T1, T2, T3, T4, TResult>(
213222
}
214223
}
215224

216-
throw new InvalidOperationException("Sequences differ in length.");
225+
throw new InvalidOperationException("The input sequences are of different lengths.");
217226
}
218227
}
219228

MoreLinq/EquiZip.g.tt

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
var ordinals = new[]
2626
{
2727
string.Empty,
28-
"first", "second", "third", "fourth",
29-
"fifth", "sixth", "seventh", "eighth"
28+
"First", "Second", "Third", "Fourth",
29+
"Fifth", "Sixth", "Seventh", "Eighth"
3030
};
3131

3232
var cardinals = new[]
@@ -45,9 +45,9 @@
4545
{
4646
IsFirst = argPosition == 1,
4747
IsLast = argPosition == argCount,
48-
Name = ordinals[argPosition],
49-
Ordinal = ordinals[argPosition],
50-
Type = $"T{argPosition}",
48+
Name = ordinals[argPosition].ToLower(),
49+
ordinal = ordinals[argPosition].ToLower(),
50+
Type = $"T{ordinals[argPosition]}",
5151
// Objects associated with the argument
5252
Enumerator = $"e{argPosition}",
5353
Value = $"v{argPosition}"
@@ -56,7 +56,7 @@
5656
select new
5757
{
5858
Arguments = args.ToList(),
59-
Cardinal = cardinals[argCount],
59+
cardinal = cardinals[argCount],
6060
TParams = string.Join(", ", from arg in args select arg.Type)
6161
};
6262
#>
@@ -72,25 +72,28 @@ namespace MoreLinq
7272
#>
7373
/// <summary>
7474
/// <para>
75-
/// Returns a sequence of projections, each projection is build from <#= o.Cardinal #> elements.
76-
/// For the N-th projection, these <#= o.Cardinal #> elements are those located
77-
/// at the N-th position of the <#= o.Cardinal #> input sequences.</para>
75+
/// Applies a specified function to the corresponding elements of <#= o.cardinal #> sequences,
76+
/// producing a sequence of the results.</para>
7877
/// <para>
7978
/// The resulting sequence has the same length as the input sequences.
8079
/// If the input sequences are of different lengths, an exception is thrown.</para>
8180
/// </summary>
8281
<# foreach (var arg in o.Arguments) { #>
83-
/// <typeparam name="<#= arg.Type #>">Type of elements in the <#= arg.Name #> input sequence.</typeparam>
82+
/// <typeparam name="<#= arg.Type #>">The type of the elements of the <#= arg.ordinal #> input sequence.</typeparam>
8483
<# } #>
85-
/// <typeparam name="TResult">Type of elements in the returned sequence.</typeparam>
84+
/// <typeparam name="TResult">The type of the elements of the result sequence.</typeparam>
8685
<# foreach (var arg in o.Arguments) { #>
87-
/// <param name="<#= arg.Name #>">The <#= arg.Ordinal #> source sequence.</param>
86+
/// <param name="<#= arg.Name #>">The <#= arg.ordinal #> sequence to merge.</param>
8887
<# } #>
8988
/// <param name="resultSelector">
90-
/// The function that make projections of <#= o.Cardinal #> elements.</param>
89+
/// A function that specifies how to merge the elements from the <#= o.cardinal #> sequences.</param>
9190
/// <returns>
92-
/// A sequence of projections built from <#= o.Cardinal #> elements,
93-
/// each element coming from one of the <#= o.Cardinal #> input sequences.</returns>
91+
/// An <code>IEnumerable</code> that contains merged elements of <#= o.cardinal #> input sequences.</returns>
92+
/// <exception cref="ArgumentNullException">
93+
<# foreach (var arg in o.Arguments) { #>
94+
/// <paramref name="<#= arg.Name #>"/><#= arg.IsLast ? " or " : ", " #>
95+
<# } #>
96+
/// <paramref name="resultSelector"/> is <code>null</code>.</exception>
9497
/// <exception cref="InvalidOperationException">
9598
/// The input sequences are of different lengths.</exception>
9699
/// <remarks>
@@ -131,7 +134,7 @@ namespace MoreLinq
131134
}
132135
}
133136

134-
throw new InvalidOperationException("Sequences differ in length.");
137+
throw new InvalidOperationException("The input sequences are of different lengths.");
135138
}
136139
}
137140

0 commit comments

Comments
 (0)