Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nullability for ZipLongest #900

Merged
merged 2 commits into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions MoreLinq.Test/ZipLongestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// limitations under the License.
#endregion

#nullable enable

namespace MoreLinq.Test
{
using System;
Expand All @@ -31,13 +33,13 @@ public class ZipLongestTest
public static readonly IEnumerable<ITestCaseData> TestData =
from e in new[]
{
new { A = Seq<int>( ), B = Seq("foo", "bar", "baz"), Result = Seq((0, "foo"), (0, "bar"), (0, "baz")) },
new { A = Seq(1 ), B = Seq("foo", "bar", "baz"), Result = Seq((1, "foo"), (0, "bar"), (0, "baz")) },
new { A = Seq(1, 2 ), B = Seq("foo", "bar", "baz"), Result = Seq((1, "foo"), (2, "bar"), (0, "baz")) },
new { A = Seq(1, 2, 3), B = Seq<string>( ), Result = Seq((1, null ), (2, null ), (3, (string) null)) },
new { A = Seq(1, 2, 3), B = Seq("foo" ), Result = Seq((1, "foo"), (2, null ), (3, null )) },
new { A = Seq(1, 2, 3), B = Seq("foo", "bar" ), Result = Seq((1, "foo"), (2, "bar"), (3, null )) },
new { A = Seq(1, 2, 3), B = Seq("foo", "bar", "baz"), Result = Seq((1, "foo"), (2, "bar"), (3, "baz")) },
new { A = Seq<int>( ), B = Seq("foo", "bar", "baz"), Result = Seq<(int, string?)>((0, "foo"), (0, "bar"), (0, "baz")) },
atifaziz marked this conversation as resolved.
Show resolved Hide resolved
new { A = Seq(1 ), B = Seq("foo", "bar", "baz"), Result = Seq<(int, string?)>((1, "foo"), (0, "bar"), (0, "baz")) },
new { A = Seq(1, 2 ), B = Seq("foo", "bar", "baz"), Result = Seq<(int, string?)>((1, "foo"), (2, "bar"), (0, "baz")) },
new { A = Seq(1, 2, 3), B = Seq<string>( ), Result = Seq<(int, string?)>((1, null ), (2, null ), (3, null )) },
new { A = Seq(1, 2, 3), B = Seq("foo" ), Result = Seq<(int, string?)>((1, "foo"), (2, null ), (3, null )) },
new { A = Seq(1, 2, 3), B = Seq("foo", "bar" ), Result = Seq<(int, string?)>((1, "foo"), (2, "bar"), (3, null )) },
new { A = Seq(1, 2, 3), B = Seq("foo", "bar", "baz"), Result = Seq<(int, string?)>((1, "foo"), (2, "bar"), (3, "baz")) },
}
select new TestCaseData(e.A, e.B)
.Returns(e.Result);
Expand Down
6 changes: 3 additions & 3 deletions MoreLinq/Extensions.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6819,7 +6819,7 @@ public static partial class ZipLongestExtension
public static IEnumerable<TResult> ZipLongest<TFirst, TSecond, TResult>(
this IEnumerable<TFirst> first,
IEnumerable<TSecond> second,
Func<TFirst, TSecond, TResult> resultSelector)
Func<TFirst?, TSecond?, TResult> resultSelector)
=> MoreEnumerable.ZipLongest(first, second, resultSelector);

/// <summary>
Expand Down Expand Up @@ -6860,7 +6860,7 @@ public static IEnumerable<TResult> ZipLongest<T1, T2, T3, TResult>(
this IEnumerable<T1> first,
IEnumerable<T2> second,
IEnumerable<T3> third,
Func<T1, T2, T3, TResult> resultSelector)
Func<T1?, T2?, T3?, TResult> resultSelector)
=> MoreEnumerable.ZipLongest(first, second, third, resultSelector);

/// <summary>
Expand Down Expand Up @@ -6905,7 +6905,7 @@ public static IEnumerable<TResult> ZipLongest<T1, T2, T3, T4, TResult>(
IEnumerable<T2> second,
IEnumerable<T3> third,
IEnumerable<T4> fourth,
Func<T1, T2, T3, T4, TResult> resultSelector)
Func<T1?, T2?, T3?, T4?, TResult> resultSelector)
=> MoreEnumerable.ZipLongest(first, second, third, fourth, resultSelector);

}
Expand Down
6 changes: 3 additions & 3 deletions MoreLinq/ZipLongest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static partial class MoreEnumerable
public static IEnumerable<TResult> ZipLongest<TFirst, TSecond, TResult>(
this IEnumerable<TFirst> first,
IEnumerable<TSecond> second,
Func<TFirst, TSecond, TResult> resultSelector)
Func<TFirst?, TSecond?, TResult> resultSelector)
{
if (first == null) throw new ArgumentNullException(nameof(first));
if (second == null) throw new ArgumentNullException(nameof(second));
Expand Down Expand Up @@ -103,7 +103,7 @@ public static IEnumerable<TResult> ZipLongest<T1, T2, T3, TResult>(
this IEnumerable<T1> first,
IEnumerable<T2> second,
IEnumerable<T3> third,
Func<T1, T2, T3, TResult> resultSelector)
Func<T1?, T2?, T3?, TResult> resultSelector)
{
if (first == null) throw new ArgumentNullException(nameof(first));
if (second == null) throw new ArgumentNullException(nameof(second));
Expand Down Expand Up @@ -155,7 +155,7 @@ public static IEnumerable<TResult> ZipLongest<T1, T2, T3, T4, TResult>(
IEnumerable<T2> second,
IEnumerable<T3> third,
IEnumerable<T4> fourth,
Func<T1, T2, T3, T4, TResult> resultSelector)
Func<T1?, T2?, T3?, T4?, TResult> resultSelector)
{
if (first == null) throw new ArgumentNullException(nameof(first));
if (second == null) throw new ArgumentNullException(nameof(second));
Expand Down