From 13429724f1dac2cd36f2e7aafcdabb0e9e8126af Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 14 Oct 2023 14:31:04 +0200 Subject: [PATCH 1/2] Change "Batch" to return arrays --- MoreLinq.Test/BatchTest.cs | 11 ----------- MoreLinq/Batch.cs | 4 ++-- MoreLinq/Extensions.g.cs | 4 ++-- MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt | 8 ++++++++ .../PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt | 8 ++++++++ .../PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt | 8 ++++++++ 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/MoreLinq.Test/BatchTest.cs b/MoreLinq.Test/BatchTest.cs index bd2db7127..ee10acfb2 100644 --- a/MoreLinq.Test/BatchTest.cs +++ b/MoreLinq.Test/BatchTest.cs @@ -62,17 +62,6 @@ public void BatchSequenceTransformingResult() result.AssertSequenceEqual(10, 26, 9); } - [Test] - public void BatchSequenceYieldsListsOfBatches() - { - var result = new[] { 1, 2, 3 }.Batch(2); - - using var reader = result.Read(); - Assert.That(reader.Read(), Is.InstanceOf(typeof(IList))); - Assert.That(reader.Read(), Is.InstanceOf(typeof(IList))); - reader.ReadEnd(); - } - [Test] public void BatchSequencesAreIndependentInstances() { diff --git a/MoreLinq/Batch.cs b/MoreLinq/Batch.cs index b8abf7f1e..5da60c07a 100644 --- a/MoreLinq/Batch.cs +++ b/MoreLinq/Batch.cs @@ -47,7 +47,7 @@ static partial class MoreEnumerable /// /// - public static IEnumerable> Batch(this IEnumerable source, int size) + public static IEnumerable Batch(this IEnumerable source, int size) { return Batch(source, size, IdFn); } @@ -80,7 +80,7 @@ public static IEnumerable> Batch(this IEnumerable< /// public static IEnumerable Batch(this IEnumerable source, int size, - Func, TResult> resultSelector) + Func resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (size <= 0) throw new ArgumentOutOfRangeException(nameof(size)); diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index b25c873fb..f492ce171 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -680,7 +680,7 @@ public static partial class BatchExtension /// /// - public static IEnumerable> Batch(this IEnumerable source, int size) + public static IEnumerable Batch(this IEnumerable source, int size) => MoreEnumerable.Batch(source, size); /// @@ -711,7 +711,7 @@ public static IEnumerable> Batch(this IEnumerable< /// public static IEnumerable Batch(this IEnumerable source, int size, - Func, TResult> resultSelector) + Func resultSelector) => MoreEnumerable.Batch(source, size, resultSelector); } diff --git a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt index 8959c7eec..fb44539c9 100644 --- a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt @@ -1,5 +1,9 @@ #nullable enable +*REMOVED*static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +*REMOVED*static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! *REMOVED*static MoreLinq.MoreEnumerable.Append(this System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! +*REMOVED*static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +*REMOVED*static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! *REMOVED*static MoreLinq.MoreEnumerable.Concat(this System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! *REMOVED*static MoreLinq.MoreEnumerable.Prepend(this System.Collections.Generic.IEnumerable! source, TSource value) -> System.Collections.Generic.IEnumerable! *REMOVED*static MoreLinq.MoreEnumerable.DistinctBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! @@ -8,7 +12,11 @@ *REMOVED*static MoreLinq.MoreEnumerable.TakeLast(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! *REMOVED*static MoreLinq.MoreEnumerable.ToHashSet(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.HashSet! *REMOVED*static MoreLinq.MoreEnumerable.ToHashSet(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.HashSet! +static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Append(System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.DistinctBy(System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.DistinctBy(System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Prepend(System.Collections.Generic.IEnumerable! source, TSource value) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index 056e1801b..ecb558421 100644 --- a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,6 +1,14 @@ #nullable enable +*REMOVED*static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +*REMOVED*static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! *REMOVED*static MoreLinq.MoreEnumerable.Append(this System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! +*REMOVED*static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +*REMOVED*static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! *REMOVED*static MoreLinq.MoreEnumerable.Concat(this System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! *REMOVED*static MoreLinq.MoreEnumerable.Prepend(this System.Collections.Generic.IEnumerable! source, TSource value) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Append(System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Prepend(System.Collections.Generic.IEnumerable! source, TSource value) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt index b025e7aed..b2858b738 100644 --- a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt @@ -1,12 +1,20 @@ #nullable enable +*REMOVED*static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +*REMOVED*static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! *REMOVED*static MoreLinq.MoreEnumerable.Append(this System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! +*REMOVED*static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +*REMOVED*static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! *REMOVED*static MoreLinq.MoreEnumerable.Concat(this System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! *REMOVED*static MoreLinq.MoreEnumerable.Prepend(this System.Collections.Generic.IEnumerable! source, TSource value) -> System.Collections.Generic.IEnumerable! *REMOVED*static MoreLinq.MoreEnumerable.SkipLast(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! *REMOVED*static MoreLinq.MoreEnumerable.TakeLast(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! *REMOVED*static MoreLinq.MoreEnumerable.ToHashSet(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.HashSet! *REMOVED*static MoreLinq.MoreEnumerable.ToHashSet(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.HashSet! +static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Append(System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Prepend(System.Collections.Generic.IEnumerable! source, TSource value) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.SkipLast(System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.TakeLast(System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! From 7ad181cb3d525997e66936c05b22413e66fc8d42 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 14 Oct 2023 19:48:33 +0200 Subject: [PATCH 2/2] Update compatibility suppressions --- MoreLinq/CompatibilitySuppressions.xml | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/MoreLinq/CompatibilitySuppressions.xml b/MoreLinq/CompatibilitySuppressions.xml index 227399b89..689b85169 100644 --- a/MoreLinq/CompatibilitySuppressions.xml +++ b/MoreLinq/CompatibilitySuppressions.xml @@ -57,6 +57,13 @@ lib/netstandard2.1/MoreLinq.dll true + + CP0002 + M:MoreLinq.Extensions.BatchExtension.Batch``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{System.Collections.Generic.IEnumerable{``0},``1}) + lib/net462/MoreLinq.dll + lib/netstandard2.0/MoreLinq.dll + true + CP0002 M:MoreLinq.MoreEnumerable.Append``1(System.Collections.Generic.IEnumerable{``0},``0) @@ -64,6 +71,13 @@ lib/netstandard2.0/MoreLinq.dll true + + CP0002 + M:MoreLinq.MoreEnumerable.Batch``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{System.Collections.Generic.IEnumerable{``0},``1}) + lib/net462/MoreLinq.dll + lib/netstandard2.0/MoreLinq.dll + true + CP0002 M:MoreLinq.MoreEnumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},``0) @@ -78,6 +92,13 @@ lib/netstandard2.0/MoreLinq.dll true + + CP0002 + M:MoreLinq.Extensions.BatchExtension.Batch``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{System.Collections.Generic.IEnumerable{``0},``1}) + lib/net6.0/MoreLinq.dll + lib/net6.0/MoreLinq.dll + true + CP0002 M:MoreLinq.MoreEnumerable.Append``1(System.Collections.Generic.IEnumerable{``0},``0) @@ -85,6 +106,13 @@ lib/net6.0/MoreLinq.dll true + + CP0002 + M:MoreLinq.MoreEnumerable.Batch``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{System.Collections.Generic.IEnumerable{``0},``1}) + lib/net6.0/MoreLinq.dll + lib/net6.0/MoreLinq.dll + true + CP0002 M:MoreLinq.MoreEnumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},``0) @@ -99,6 +127,13 @@ lib/net6.0/MoreLinq.dll true + + CP0002 + M:MoreLinq.Extensions.BatchExtension.Batch``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{System.Collections.Generic.IEnumerable{``0},``1}) + lib/netstandard2.0/MoreLinq.dll + lib/netstandard2.0/MoreLinq.dll + true + CP0002 M:MoreLinq.MoreEnumerable.Append``1(System.Collections.Generic.IEnumerable{``0},``0) @@ -106,6 +141,13 @@ lib/netstandard2.0/MoreLinq.dll true + + CP0002 + M:MoreLinq.MoreEnumerable.Batch``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{System.Collections.Generic.IEnumerable{``0},``1}) + lib/netstandard2.0/MoreLinq.dll + lib/netstandard2.0/MoreLinq.dll + true + CP0002 M:MoreLinq.MoreEnumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},``0) @@ -120,6 +162,13 @@ lib/netstandard2.0/MoreLinq.dll true + + CP0002 + M:MoreLinq.Extensions.BatchExtension.Batch``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{System.Collections.Generic.IEnumerable{``0},``1}) + lib/netstandard2.1/MoreLinq.dll + lib/netstandard2.1/MoreLinq.dll + true + CP0002 M:MoreLinq.MoreEnumerable.Append``1(System.Collections.Generic.IEnumerable{``0},``0) @@ -127,6 +176,13 @@ lib/netstandard2.1/MoreLinq.dll true + + CP0002 + M:MoreLinq.MoreEnumerable.Batch``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{System.Collections.Generic.IEnumerable{``0},``1}) + lib/netstandard2.1/MoreLinq.dll + lib/netstandard2.1/MoreLinq.dll + true + CP0002 M:MoreLinq.MoreEnumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},``0)