From 511bcaba5a2a72f65f53d862a3403b45e512eacd Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Mon, 13 Nov 2023 21:49:04 -0500 Subject: [PATCH 01/51] introduce duplicates extension with unit test and documentations --- MoreLinq.Test/DuplicatesTest.cs | 220 ++++++++++++++++++ MoreLinq/Duplicates.cs | 69 ++++++ MoreLinq/Extensions.g.cs | 54 +++++ .../PublicAPI/net6.0/PublicAPI.Unshipped.txt | 9 + .../netstandard2.0/PublicAPI.Unshipped.txt | 9 + .../netstandard2.1/PublicAPI.Unshipped.txt | 9 + 6 files changed, 370 insertions(+) create mode 100644 MoreLinq.Test/DuplicatesTest.cs create mode 100644 MoreLinq/Duplicates.cs diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs new file mode 100644 index 000000000..8bead5d37 --- /dev/null +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -0,0 +1,220 @@ +namespace MoreLinq.Test +{ + using System.Collections.Generic; + using NUnit.Framework; + + [TestFixture] + public class DuplicatesTest + { + [Test] + public void When_Asking_For_Duplicates_On_Sequence_Without_Duplicates_Then_Empty_Sequence_Is_Returned() + { + var stringArray = new[] + { + "FirstElement", + "SecondElement", + "ThirdElement" + }; + + var duplicates = stringArray.Duplicates(); + + Assert.That(duplicates, Is.Empty); + } + + [Test] + public void When_Asking_For_Duplicates_On_Sequence_Projection_Without_Duplicates_Then_Then_Empty_Sequence_Is_Returned() + { + var dummyClasses = new DummyClass[] + { + new("FirstElement"), + new("SecondElement"), + new("ThirdElement") + }; + + var duplicates = dummyClasses.Duplicates(x => x.ComparableString); + + Assert.That(duplicates, Is.Empty); + } + + [Test] + public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_True_Is_Returned() + { + var stringArray = new[] + { + "FirstElement", + "DUPLICATED_STRING", + "DUPLICATED_STRING", + "ThirdElement" + }; + + var duplicates = stringArray.Duplicates(); + + Assert.That(duplicates, Contains.Item("DUPLICATED_STRING")); + } + + [Test] + public void When_Asking_For_Duplicates_On_Sequence_Projection_With_Duplicates_Then_True_Is_Returned() + { + var dummyClass = new DummyClass("DUPLICATED_STRING"); + var dummyClasses = new DummyClass[] + { + new("FirstElement"), + dummyClass, + dummyClass, + new("ThirdElement") + }; + + var duplicates = dummyClasses.Duplicates(x => x.ComparableString); + + Assert.That(duplicates, Contains.Item(dummyClass)); + } + + [Test] + public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_It_Does_Not_Iterate_Unnecessary_On_Elements() + { + var source = MoreEnumerable.From(() => "FirstElement", + () => "DUPLICATED_STRING", + () => "DUPLICATED_STRING", + () => throw new TestException()); + + Assert.DoesNotThrow(() => source.Duplicates()); + } + + [Test] + public void When_Asking_For_Duplicates_On_Sequence_Projection_With_Duplicates_Then_It_Does_Not_Iterate_Unnecessary_On_Elements() + { + var source = MoreEnumerable.From(() => new DummyClass("FirstElement"), + () => new DummyClass("DUPLICATED_STRING"), + () => new DummyClass("DUPLICATED_STRING"), + () => throw new TestException()); + + Assert.DoesNotThrow(() => source.Duplicates(x => x.ComparableString)); + } + + [Test] + public void When_Asking_Duplicates_Then_It_Is_Executed_Right_Away() + { + _ = Assert.Throws(() => new BreakingSequence().Duplicates().Consume()); + } + + [Test] + public void When_Asking_Duplicates_On_Sequence_Projection_Then_It_Is_Executed_Right_Away() + { + _ = Assert.Throws(() => new BreakingSequence().Duplicates(x => x.ComparableString).Consume()); + } + + [Test] + public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Comparer_Then_True_Is_Returned() + { + var stringArray = new[] + { + "FirstElement", + "SecondElement", + "ThirdElement" + }; + + var duplicates = stringArray.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); + + Assert.That(duplicates, Contains.Item(stringArray[1])); + Assert.That(duplicates, Contains.Item(stringArray[2])); + } + + [Test] + public void When_Asking_For_Duplicates_On_Sequence_Projection_With_Custom_Always_True_Comparer_Then_True_Is_Returned() + { + var dummyClasses = new DummyClass[] + { + new("FirstElement"), + new("SecondElement"), + new("ThirdElement") + }; + + var duplicates = dummyClasses.Duplicates(x => x.ComparableString, new DummyStringAlwaysTrueComparer()).ToArray(); + + Assert.That(duplicates, Contains.Item(dummyClasses[1])); + Assert.That(duplicates, Contains.Item(dummyClasses[2])); + } + + [Test] + public void When_Asking_For_Duplicates_On_None_Duplicates_Sequence_With_Custom_Always_True_Comparer_Then_True_Is_Returned() + { + var stringArray = new[] + { + "FirstElement", + "SecondElement", + "ThirdElement" + }; + + var duplicates = stringArray.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); + + Assert.That(duplicates, Contains.Item(stringArray[1])); + Assert.That(duplicates, Contains.Item(stringArray[2])); + } + + [Test] + public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_False_Comparer_Then_Then_Empty_Sequence_Is_Returned() + { + var stringArray = new[] + { + "FirstElement", + "SecondElement", + "ThirdElement" + }; + + var duplicates = stringArray.Duplicates(new DummyStringAlwaysFalseComparer()); + + Assert.That(duplicates, Is.Empty); + } + + [Test] + public void When_Asking_For_Duplicates_On_Multiple_Duplicates_Sequence_With_Custom_Always_False_Comparer_Then_Then_Empty_Sequence_Is_Returned() + { + var stringArray = new[] + { + "DUPLICATED_STRING", + "DUPLICATED_STRING", + "DUPLICATED_STRING" + }; + + var duplicates = stringArray.Duplicates(new DummyStringAlwaysFalseComparer()); + + Assert.That(duplicates, Is.Empty); + } + + [Test] + public void When_Asking_For_Duplicates_On_Multiple_Duplicates_Sequence_Projection_With_Custom_Always_False_Comparer_Then_Then_Empty_Sequence_Is_Returned() + { + var dummyClasses = new DummyClass[] + { + new("DUPLICATED_STRING"), + new("DUPLICATED_STRING"), + new("DUPLICATED_STRING") + }; + + var duplicates = dummyClasses.Duplicates(x => x.ComparableString, new DummyStringAlwaysFalseComparer()); + + Assert.That(duplicates, Is.Empty); + } + + sealed class DummyClass + { + public string ComparableString { get; } + + public DummyClass(string comparableString) => ComparableString = comparableString; + } + + sealed class DummyStringAlwaysTrueComparer : IEqualityComparer + { + public bool Equals(string? x, string? y) => true; + + public int GetHashCode(string obj) => 0; + } + + sealed class DummyStringAlwaysFalseComparer : IEqualityComparer + { + public bool Equals(string? x, string? y) => false; + + public int GetHashCode(string obj) => 0; + } + } +} diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs new file mode 100644 index 000000000..52aa2292f --- /dev/null +++ b/MoreLinq/Duplicates.cs @@ -0,0 +1,69 @@ +namespace MoreLinq +{ + using System; + using System.Collections.Generic; + + static partial class MoreEnumerable + { + /// + /// Returns all duplicated elements of the given source. + /// + /// source sequence. + /// The type of the elements in the source sequence. + /// all elements that are duplicated. + public static IEnumerable Duplicates(this IEnumerable source) + => Duplicates(source, EqualityComparer.Default); + + /// + /// Returns all duplicated elements of the given source, using the specified element equality comparer. + /// + /// source sequence. + /// The equality comparer to use to determine whether or not keys are equal. + /// If null, the default equality comparer for TSource is used. + /// The type of the elements in the source sequence + /// all elements of the source sequence that are duplicated, based on the provided equality comparer + public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer comparer) + => Duplicates(source, IdFn, comparer); + + /// + /// Returns all duplicated elements of the given source, using the specified element equality comparer + /// + /// source sequence. + /// Projection for determining duplication + /// Type of the source sequence + /// Type of the projected element + /// all elements of the source sequence that are duplicated, based on the provided equality comparer + public static IEnumerable Duplicates(this IEnumerable source, Func keySelector) + => Duplicates(source, keySelector, EqualityComparer.Default); + + /// + /// Returns all duplicated elements of the given source, using the specified element equality comparer + /// + /// source sequence. + /// Projection for determining duplication + /// The equality comparer to use to determine whether or not keys are equal. + /// If null, the default equality comparer for TSource is used. + /// Type of the source sequence + /// Type of the projected element + /// all elements of the source sequence that are duplicated, based on the provided equality comparer + /// is null. + /// is null. + /// is null. + public static IEnumerable Duplicates(this IEnumerable source, Func keySelector, IEqualityComparer comparer) + { + if (source is null) throw new ArgumentNullException(nameof(source)); + if (keySelector is null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer is null) throw new ArgumentNullException(nameof(comparer)); + + var enumeratedElements = new HashSet(comparer); + + foreach (var element in source) + { + if (enumeratedElements.Add(keySelector(element)) is false) + { + yield return element; + } + } + } + } +} diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index b7fcf096d..4a1c26fcb 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1283,6 +1283,60 @@ public static IEnumerable DistinctBy(this IEnumerableDuplicates extension. + + [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] + public static partial class DuplicatesExtension + { + /// + /// Returns all duplicated elements of the given source. + /// + /// source sequence. + /// The type of the elements in the source sequence. + /// all elements that are duplicated. + public static IEnumerable Duplicates(this IEnumerable source) + => MoreEnumerable.Duplicates(source); + + /// + /// Returns all duplicated elements of the given source, using the specified element equality comparer. + /// + /// source sequence. + /// The equality comparer to use to determine whether or not keys are equal. + /// If null, the default equality comparer for TSource is used. + /// The type of the elements in the source sequence + /// all elements of the source sequence that are duplicated, based on the provided equality comparer + public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer comparer) + => MoreEnumerable.Duplicates(source, comparer); + + /// + /// Returns all duplicated elements of the given source, using the specified element equality comparer + /// + /// source sequence. + /// Projection for determining duplication + /// Type of the source sequence + /// Type of the projected element + /// all elements of the source sequence that are duplicated, based on the provided equality comparer + public static IEnumerable Duplicates(this IEnumerable source, Func keySelector) + => MoreEnumerable.Duplicates(source, keySelector); + + /// + /// Returns all duplicated elements of the given source, using the specified element equality comparer + /// + /// source sequence. + /// Projection for determining duplication + /// The equality comparer to use to determine whether or not keys are equal. + /// If null, the default equality comparer for TSource is used. + /// Type of the source sequence + /// Type of the projected element + /// all elements of the source sequence that are duplicated, based on the provided equality comparer + /// is null. + /// is null. + /// is null. + public static IEnumerable Duplicates(this IEnumerable source, Func keySelector, IEqualityComparer comparer) + => MoreEnumerable.Duplicates(source, keySelector, comparer); + + } + /// EndsWith extension. [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] diff --git a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt index 7dc5c5811..00003c096 100644 --- a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt @@ -1 +1,10 @@ #nullable enable +MoreLinq.Extensions.DuplicatesExtension +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index 7dc5c5811..00003c096 100644 --- a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -1 +1,10 @@ #nullable enable +MoreLinq.Extensions.DuplicatesExtension +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt index 7dc5c5811..00003c096 100644 --- a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt @@ -1 +1,10 @@ #nullable enable +MoreLinq.Extensions.DuplicatesExtension +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! From 6a21b2e58762ae187e183337bfe7f8c240dcafe5 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 08:48:00 -0500 Subject: [PATCH 02/51] add local function to trigger validation before enumeration --- MoreLinq/Duplicates.cs | 16 ++++++++-------- MoreLinq/Extensions.g.cs | 5 ++--- .../PublicAPI/net6.0/PublicAPI.Unshipped.txt | 8 ++++---- .../netstandard2.0/PublicAPI.Unshipped.txt | 8 ++++---- .../netstandard2.1/PublicAPI.Unshipped.txt | 8 ++++---- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 52aa2292f..0202d9dad 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -22,7 +22,7 @@ public static IEnumerable Duplicates(this IEnumerable source) /// If null, the default equality comparer for TSource is used. /// The type of the elements in the source sequence /// all elements of the source sequence that are duplicated, based on the provided equality comparer - public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer comparer) + public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) => Duplicates(source, IdFn, comparer); /// @@ -48,20 +48,20 @@ public static IEnumerable Duplicates(this IEnumerableall elements of the source sequence that are duplicated, based on the provided equality comparer /// is null. /// is null. - /// is null. - public static IEnumerable Duplicates(this IEnumerable source, Func keySelector, IEqualityComparer comparer) + public static IEnumerable Duplicates(this IEnumerable source, Func keySelector, IEqualityComparer? comparer) { if (source is null) throw new ArgumentNullException(nameof(source)); if (keySelector is null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer is null) throw new ArgumentNullException(nameof(comparer)); - var enumeratedElements = new HashSet(comparer); + return GetDuplicates(); - foreach (var element in source) + IEnumerable GetDuplicates() { - if (enumeratedElements.Add(keySelector(element)) is false) + var enumeratedElements = new HashSet(comparer); + foreach (var element in source) { - yield return element; + if (enumeratedElements.Add(keySelector(element)) is false) + yield return element; } } } diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 4a1c26fcb..cee86e2b0 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1305,7 +1305,7 @@ public static IEnumerable Duplicates(this IEnumerable source) /// If null, the default equality comparer for TSource is used. /// The type of the elements in the source sequence /// all elements of the source sequence that are duplicated, based on the provided equality comparer - public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer comparer) + public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) => MoreEnumerable.Duplicates(source, comparer); /// @@ -1331,8 +1331,7 @@ public static IEnumerable Duplicates(this IEnumerableall elements of the source sequence that are duplicated, based on the provided equality comparer /// is null. /// is null. - /// is null. - public static IEnumerable Duplicates(this IEnumerable source, Func keySelector, IEqualityComparer comparer) + public static IEnumerable Duplicates(this IEnumerable source, Func keySelector, IEqualityComparer? comparer) => MoreEnumerable.Duplicates(source, keySelector, comparer); } diff --git a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt index 00003c096..e3e5438d7 100644 --- a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt @@ -1,10 +1,10 @@ #nullable enable MoreLinq.Extensions.DuplicatesExtension static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index 00003c096..e3e5438d7 100644 --- a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,10 +1,10 @@ #nullable enable MoreLinq.Extensions.DuplicatesExtension static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt index 00003c096..e3e5438d7 100644 --- a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt @@ -1,10 +1,10 @@ #nullable enable MoreLinq.Extensions.DuplicatesExtension static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! From ff0c3ca6ae14b134a4b0ba95bd2190138d49728b Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 17:07:28 -0500 Subject: [PATCH 03/51] getting rid of KeySelector --- MoreLinq.Test/DuplicatesTest.cs | 80 ------------------- MoreLinq/Duplicates.cs | 32 +------- MoreLinq/Extensions.g.cs | 29 +------ .../PublicAPI/net6.0/PublicAPI.Unshipped.txt | 8 +- .../netstandard2.0/PublicAPI.Unshipped.txt | 8 +- .../netstandard2.1/PublicAPI.Unshipped.txt | 8 +- 6 files changed, 11 insertions(+), 154 deletions(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index 8bead5d37..9baf47284 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -21,21 +21,6 @@ public void When_Asking_For_Duplicates_On_Sequence_Without_Duplicates_Then_Empty Assert.That(duplicates, Is.Empty); } - [Test] - public void When_Asking_For_Duplicates_On_Sequence_Projection_Without_Duplicates_Then_Then_Empty_Sequence_Is_Returned() - { - var dummyClasses = new DummyClass[] - { - new("FirstElement"), - new("SecondElement"), - new("ThirdElement") - }; - - var duplicates = dummyClasses.Duplicates(x => x.ComparableString); - - Assert.That(duplicates, Is.Empty); - } - [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_True_Is_Returned() { @@ -52,23 +37,6 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_True_Is_ Assert.That(duplicates, Contains.Item("DUPLICATED_STRING")); } - [Test] - public void When_Asking_For_Duplicates_On_Sequence_Projection_With_Duplicates_Then_True_Is_Returned() - { - var dummyClass = new DummyClass("DUPLICATED_STRING"); - var dummyClasses = new DummyClass[] - { - new("FirstElement"), - dummyClass, - dummyClass, - new("ThirdElement") - }; - - var duplicates = dummyClasses.Duplicates(x => x.ComparableString); - - Assert.That(duplicates, Contains.Item(dummyClass)); - } - [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_It_Does_Not_Iterate_Unnecessary_On_Elements() { @@ -80,29 +48,12 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_It_Does_ Assert.DoesNotThrow(() => source.Duplicates()); } - [Test] - public void When_Asking_For_Duplicates_On_Sequence_Projection_With_Duplicates_Then_It_Does_Not_Iterate_Unnecessary_On_Elements() - { - var source = MoreEnumerable.From(() => new DummyClass("FirstElement"), - () => new DummyClass("DUPLICATED_STRING"), - () => new DummyClass("DUPLICATED_STRING"), - () => throw new TestException()); - - Assert.DoesNotThrow(() => source.Duplicates(x => x.ComparableString)); - } - [Test] public void When_Asking_Duplicates_Then_It_Is_Executed_Right_Away() { _ = Assert.Throws(() => new BreakingSequence().Duplicates().Consume()); } - [Test] - public void When_Asking_Duplicates_On_Sequence_Projection_Then_It_Is_Executed_Right_Away() - { - _ = Assert.Throws(() => new BreakingSequence().Duplicates(x => x.ComparableString).Consume()); - } - [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Comparer_Then_True_Is_Returned() { @@ -119,22 +70,6 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Compa Assert.That(duplicates, Contains.Item(stringArray[2])); } - [Test] - public void When_Asking_For_Duplicates_On_Sequence_Projection_With_Custom_Always_True_Comparer_Then_True_Is_Returned() - { - var dummyClasses = new DummyClass[] - { - new("FirstElement"), - new("SecondElement"), - new("ThirdElement") - }; - - var duplicates = dummyClasses.Duplicates(x => x.ComparableString, new DummyStringAlwaysTrueComparer()).ToArray(); - - Assert.That(duplicates, Contains.Item(dummyClasses[1])); - Assert.That(duplicates, Contains.Item(dummyClasses[2])); - } - [Test] public void When_Asking_For_Duplicates_On_None_Duplicates_Sequence_With_Custom_Always_True_Comparer_Then_True_Is_Returned() { @@ -181,21 +116,6 @@ public void When_Asking_For_Duplicates_On_Multiple_Duplicates_Sequence_With_Cust Assert.That(duplicates, Is.Empty); } - [Test] - public void When_Asking_For_Duplicates_On_Multiple_Duplicates_Sequence_Projection_With_Custom_Always_False_Comparer_Then_Then_Empty_Sequence_Is_Returned() - { - var dummyClasses = new DummyClass[] - { - new("DUPLICATED_STRING"), - new("DUPLICATED_STRING"), - new("DUPLICATED_STRING") - }; - - var duplicates = dummyClasses.Duplicates(x => x.ComparableString, new DummyStringAlwaysFalseComparer()); - - Assert.That(duplicates, Is.Empty); - } - sealed class DummyClass { public string ComparableString { get; } diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 0202d9dad..91d8c2b35 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -14,53 +14,27 @@ static partial class MoreEnumerable public static IEnumerable Duplicates(this IEnumerable source) => Duplicates(source, EqualityComparer.Default); - /// - /// Returns all duplicated elements of the given source, using the specified element equality comparer. - /// - /// source sequence. - /// The equality comparer to use to determine whether or not keys are equal. - /// If null, the default equality comparer for TSource is used. - /// The type of the elements in the source sequence - /// all elements of the source sequence that are duplicated, based on the provided equality comparer - public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) - => Duplicates(source, IdFn, comparer); - - /// - /// Returns all duplicated elements of the given source, using the specified element equality comparer - /// - /// source sequence. - /// Projection for determining duplication - /// Type of the source sequence - /// Type of the projected element - /// all elements of the source sequence that are duplicated, based on the provided equality comparer - public static IEnumerable Duplicates(this IEnumerable source, Func keySelector) - => Duplicates(source, keySelector, EqualityComparer.Default); - /// /// Returns all duplicated elements of the given source, using the specified element equality comparer /// /// source sequence. - /// Projection for determining duplication /// The equality comparer to use to determine whether or not keys are equal. /// If null, the default equality comparer for TSource is used. /// Type of the source sequence - /// Type of the projected element /// all elements of the source sequence that are duplicated, based on the provided equality comparer /// is null. - /// is null. - public static IEnumerable Duplicates(this IEnumerable source, Func keySelector, IEqualityComparer? comparer) + public static IEnumerable Duplicates(this IEnumerable source,IEqualityComparer? comparer) { if (source is null) throw new ArgumentNullException(nameof(source)); - if (keySelector is null) throw new ArgumentNullException(nameof(keySelector)); return GetDuplicates(); IEnumerable GetDuplicates() { - var enumeratedElements = new HashSet(comparer); + var enumeratedElements = new HashSet(comparer); foreach (var element in source) { - if (enumeratedElements.Add(keySelector(element)) is false) + if (enumeratedElements.Add(element) is false) yield return element; } } diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index cee86e2b0..40d13b980 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1297,42 +1297,17 @@ public static partial class DuplicatesExtension public static IEnumerable Duplicates(this IEnumerable source) => MoreEnumerable.Duplicates(source); - /// - /// Returns all duplicated elements of the given source, using the specified element equality comparer. - /// - /// source sequence. - /// The equality comparer to use to determine whether or not keys are equal. - /// If null, the default equality comparer for TSource is used. - /// The type of the elements in the source sequence - /// all elements of the source sequence that are duplicated, based on the provided equality comparer - public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) - => MoreEnumerable.Duplicates(source, comparer); - /// /// Returns all duplicated elements of the given source, using the specified element equality comparer /// /// source sequence. - /// Projection for determining duplication - /// Type of the source sequence - /// Type of the projected element - /// all elements of the source sequence that are duplicated, based on the provided equality comparer - public static IEnumerable Duplicates(this IEnumerable source, Func keySelector) - => MoreEnumerable.Duplicates(source, keySelector); - - /// - /// Returns all duplicated elements of the given source, using the specified element equality comparer - /// - /// source sequence. - /// Projection for determining duplication /// The equality comparer to use to determine whether or not keys are equal. /// If null, the default equality comparer for TSource is used. /// Type of the source sequence - /// Type of the projected element /// all elements of the source sequence that are duplicated, based on the provided equality comparer /// is null. - /// is null. - public static IEnumerable Duplicates(this IEnumerable source, Func keySelector, IEqualityComparer? comparer) - => MoreEnumerable.Duplicates(source, keySelector, comparer); + public static IEnumerable Duplicates(this IEnumerable source,IEqualityComparer? comparer) + => MoreEnumerable.Duplicates(source, comparer); } diff --git a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt index e3e5438d7..aec636150 100644 --- a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt @@ -1,10 +1,6 @@ #nullable enable MoreLinq.Extensions.DuplicatesExtension static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index e3e5438d7..aec636150 100644 --- a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,10 +1,6 @@ #nullable enable MoreLinq.Extensions.DuplicatesExtension static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt index e3e5438d7..aec636150 100644 --- a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt @@ -1,10 +1,6 @@ #nullable enable MoreLinq.Extensions.DuplicatesExtension static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! From 79a5e0cc60295205a9f72e069012775cf1508a26 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 17:09:19 -0500 Subject: [PATCH 04/51] add readme info --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 98d40de8a..3e9dd7d17 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,12 @@ projected type. This method has 2 overloads. +### Duplicates + +Returns all duplicated elements of the given source, using the specified element equality comparer + +This method has 2 overloads. + ### EndsWith Determines whether the end of the first sequence is equivalent to the second From 8db56cdd13b01d4d5d078d6017b60ba68eb50df4 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 17:10:23 -0500 Subject: [PATCH 05/51] add entry in csproj --- MoreLinq/MoreLinq.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/MoreLinq/MoreLinq.csproj b/MoreLinq/MoreLinq.csproj index fea6ba41c..3ca59d89d 100644 --- a/MoreLinq/MoreLinq.csproj +++ b/MoreLinq/MoreLinq.csproj @@ -27,6 +27,7 @@ - CountDown - Consume - DistinctBy + - Duplicates - EndsWith - EquiZip - Evaluate From 00259ce8718a231e19145afac0ef5e7f88c2de80 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 17:12:56 -0500 Subject: [PATCH 06/51] update coyprights --- bld/Copyright.props | 1 + 1 file changed, 1 insertion(+) diff --git a/bld/Copyright.props b/bld/Copyright.props index 62e21672d..f0bf90c0a 100644 --- a/bld/Copyright.props +++ b/bld/Copyright.props @@ -7,6 +7,7 @@ Portions © 2015 Felipe Sateler, “sholland”. Portions © 2016 Andreas Gullberg Larsen, Leandro F. Vieira (leandromoh). Portions © 2017 Jonas Nyrup (jnyrup). + Portions © 2023 Julien Aspirot (julienasp). Portions © Microsoft. All rights reserved. From ec22a9fcb53ad0057e65c2aafee36e0951d61556 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 17:13:35 -0500 Subject: [PATCH 07/51] use null instead of default --- MoreLinq/Duplicates.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 91d8c2b35..ad8a2a06f 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -12,7 +12,7 @@ static partial class MoreEnumerable /// The type of the elements in the source sequence. /// all elements that are duplicated. public static IEnumerable Duplicates(this IEnumerable source) - => Duplicates(source, EqualityComparer.Default); + => Duplicates(source, null); /// /// Returns all duplicated elements of the given source, using the specified element equality comparer @@ -23,7 +23,7 @@ public static IEnumerable Duplicates(this IEnumerable source) /// Type of the source sequence /// all elements of the source sequence that are duplicated, based on the provided equality comparer /// is null. - public static IEnumerable Duplicates(this IEnumerable source,IEqualityComparer? comparer) + public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) { if (source is null) throw new ArgumentNullException(nameof(source)); From b62d725a4cd7f6f2bc23667df0361254ee2bda2f Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 17:15:16 -0500 Subject: [PATCH 08/51] cleanup test --- MoreLinq.Test/DuplicatesTest.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index 9baf47284..21520d096 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -116,13 +116,6 @@ public void When_Asking_For_Duplicates_On_Multiple_Duplicates_Sequence_With_Cust Assert.That(duplicates, Is.Empty); } - sealed class DummyClass - { - public string ComparableString { get; } - - public DummyClass(string comparableString) => ComparableString = comparableString; - } - sealed class DummyStringAlwaysTrueComparer : IEqualityComparer { public bool Equals(string? x, string? y) => true; From 35dc3cdf8f79dfb803ce7352dca93879e370999f Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 17:16:32 -0500 Subject: [PATCH 09/51] add copyright region --- MoreLinq.Test/DuplicatesTest.cs | 16 ++++++++++++++++ MoreLinq/Duplicates.cs | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index 21520d096..aaa26232b 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -1,3 +1,19 @@ +#region License and Terms +// MoreLINQ - Extensions to LINQ to Objects +// Copyright (c) 2023 Julien Aspirot. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion namespace MoreLinq.Test { using System.Collections.Generic; diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index ad8a2a06f..8d13dd1b9 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -1,3 +1,19 @@ +#region License and Terms +// MoreLINQ - Extensions to LINQ to Objects +// Copyright (c) 2023 Julien Aspirot. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion namespace MoreLinq { using System; From 277436a72265b68205301e65cafcb318a043b103 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 19:21:36 -0500 Subject: [PATCH 10/51] place arrow on the right --- MoreLinq/Duplicates.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 8d13dd1b9..c25b31673 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -27,8 +27,7 @@ static partial class MoreEnumerable /// source sequence. /// The type of the elements in the source sequence. /// all elements that are duplicated. - public static IEnumerable Duplicates(this IEnumerable source) - => Duplicates(source, null); + public static IEnumerable Duplicates(this IEnumerable source) => Duplicates(source, null); /// /// Returns all duplicated elements of the given source, using the specified element equality comparer From a5f06e373b208195720ac9021e4bf07782916eb3 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 19:23:06 -0500 Subject: [PATCH 11/51] apply rename keySet --- MoreLinq/Duplicates.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index c25b31673..da4e58e42 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -46,10 +46,10 @@ public static IEnumerable Duplicates(this IEnumerable IEnumerable GetDuplicates() { - var enumeratedElements = new HashSet(comparer); + var keySet = new HashSet(comparer); foreach (var element in source) { - if (enumeratedElements.Add(element) is false) + if (keySet.Add(element) is false) yield return element; } } From 17425154a3c621317e3c330fb48fde70c42fcc4f Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 19:24:36 -0500 Subject: [PATCH 12/51] replace pattern matching with not operator --- MoreLinq/Duplicates.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index da4e58e42..c9ab9055b 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -49,7 +49,7 @@ IEnumerable GetDuplicates() var keySet = new HashSet(comparer); foreach (var element in source) { - if (keySet.Add(element) is false) + if (!keySet.Add(element)) yield return element; } } From 4ed65c961814b031bc3626c8c33b349973d6e284 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 19:28:04 -0500 Subject: [PATCH 13/51] add isLazy test --- MoreLinq.Test/DuplicatesTest.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index aaa26232b..65263de5a 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -22,6 +22,12 @@ namespace MoreLinq.Test [TestFixture] public class DuplicatesTest { + [Test] + public void Duplicates_IsLazy() + { + _ = new BreakingSequence().Duplicates(); + } + [Test] public void When_Asking_For_Duplicates_On_Sequence_Without_Duplicates_Then_Empty_Sequence_Is_Returned() { @@ -64,12 +70,6 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_It_Does_ Assert.DoesNotThrow(() => source.Duplicates()); } - [Test] - public void When_Asking_Duplicates_Then_It_Is_Executed_Right_Away() - { - _ = Assert.Throws(() => new BreakingSequence().Duplicates().Consume()); - } - [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Comparer_Then_True_Is_Returned() { From a760553b7293730ebb66c4c2295bfbdc4b010a0a Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 19:48:20 -0500 Subject: [PATCH 14/51] change implementation to return at most once of each duplicates --- MoreLinq.Test/DuplicatesTest.cs | 41 +++++++++++++++------------------ MoreLinq/Duplicates.cs | 5 +++- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index 65263de5a..cbf72e2eb 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -44,50 +44,46 @@ public void When_Asking_For_Duplicates_On_Sequence_Without_Duplicates_Then_Empty } [Test] - public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_True_Is_Returned() + public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_Duplicates_Are_Returned() { var stringArray = new[] { "FirstElement", "DUPLICATED_STRING", "DUPLICATED_STRING", + "DUPLICATED_STRING", "ThirdElement" }; - var duplicates = stringArray.Duplicates(); + var duplicates = stringArray.Duplicates().ToArray(); Assert.That(duplicates, Contains.Item("DUPLICATED_STRING")); + Assert.That(duplicates.AtMost(1), Is.True); } [Test] - public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_It_Does_Not_Iterate_Unnecessary_On_Elements() - { - var source = MoreEnumerable.From(() => "FirstElement", - () => "DUPLICATED_STRING", - () => "DUPLICATED_STRING", - () => throw new TestException()); - - Assert.DoesNotThrow(() => source.Duplicates()); - } - - [Test] - public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Comparer_Then_True_Is_Returned() + public void When_Asking_For_Duplicates_On_Sequence_With_Multiple_Duplicates_Then_Duplicates_Are_Returned() { var stringArray = new[] { "FirstElement", - "SecondElement", - "ThirdElement" + "DUPLICATED_STRING", + "DUPLICATED_STRING", + "DUPLICATED_STRING", + "ThirdElement", + "SECOND_DUPLICATED_STRING", + "SECOND_DUPLICATED_STRING" }; - var duplicates = stringArray.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); + var duplicates = stringArray.Duplicates().ToArray(); - Assert.That(duplicates, Contains.Item(stringArray[1])); - Assert.That(duplicates, Contains.Item(stringArray[2])); + Assert.That(duplicates, Contains.Item("DUPLICATED_STRING")); + Assert.That(duplicates, Contains.Item("SECOND_DUPLICATED_STRING")); + Assert.That(duplicates.AtMost(2), Is.True); } [Test] - public void When_Asking_For_Duplicates_On_None_Duplicates_Sequence_With_Custom_Always_True_Comparer_Then_True_Is_Returned() + public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Comparer_Then_Duplicates_Are_Returned() { var stringArray = new[] { @@ -97,9 +93,8 @@ public void When_Asking_For_Duplicates_On_None_Duplicates_Sequence_With_Custom_A }; var duplicates = stringArray.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); - - Assert.That(duplicates, Contains.Item(stringArray[1])); - Assert.That(duplicates, Contains.Item(stringArray[2])); + + Assert.That(duplicates.AtMost(1), Is.True); } [Test] diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index c9ab9055b..0b5d3d7a9 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -47,10 +47,13 @@ public static IEnumerable Duplicates(this IEnumerable IEnumerable GetDuplicates() { var keySet = new HashSet(comparer); + var yieldSet = new HashSet(comparer); foreach (var element in source) { - if (!keySet.Add(element)) + if (!keySet.Add(element) && yieldSet.Add(element)) + { yield return element; + } } } } From c57353c823f583df29a831b68505057bbd467a75 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 20:01:27 -0500 Subject: [PATCH 15/51] re-run build.cmd --- MoreLinq/Extensions.g.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 40d13b980..8edf326a2 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1294,8 +1294,7 @@ public static partial class DuplicatesExtension /// source sequence. /// The type of the elements in the source sequence. /// all elements that are duplicated. - public static IEnumerable Duplicates(this IEnumerable source) - => MoreEnumerable.Duplicates(source); + public static IEnumerable Duplicates(this IEnumerable source) => MoreEnumerable.Duplicates(source); /// /// Returns all duplicated elements of the given source, using the specified element equality comparer @@ -1306,7 +1305,7 @@ public static IEnumerable Duplicates(this IEnumerable source) /// Type of the source sequence /// all elements of the source sequence that are duplicated, based on the provided equality comparer /// is null. - public static IEnumerable Duplicates(this IEnumerable source,IEqualityComparer? comparer) + public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) => MoreEnumerable.Duplicates(source, comparer); } From 450cda7b73bc86f62cc236f4c6b08210b83dc4b4 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 20:02:30 -0500 Subject: [PATCH 16/51] fix formating --- MoreLinq.Test/DuplicatesTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index cbf72e2eb..b7b5242c5 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -93,7 +93,7 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Compa }; var duplicates = stringArray.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); - + Assert.That(duplicates.AtMost(1), Is.True); } From a19b89f7275c3d7b33322a661ae9fc2faa90fb01 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Tue, 14 Nov 2023 20:59:19 -0500 Subject: [PATCH 17/51] fix spaces --- bld/Copyright.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/Copyright.props b/bld/Copyright.props index f0bf90c0a..96a381457 100644 --- a/bld/Copyright.props +++ b/bld/Copyright.props @@ -7,7 +7,7 @@ Portions © 2015 Felipe Sateler, “sholland”. Portions © 2016 Andreas Gullberg Larsen, Leandro F. Vieira (leandromoh). Portions © 2017 Jonas Nyrup (jnyrup). - Portions © 2023 Julien Aspirot (julienasp). + Portions © 2023 Julien Aspirot (julienasp). Portions © Microsoft. All rights reserved. From 2fe88a550fee99a313f46d7865a72a96eb815324 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:18:20 -0500 Subject: [PATCH 18/51] add blanklines --- MoreLinq.Test/DuplicatesTest.cs | 1 + MoreLinq/Duplicates.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index b7b5242c5..b6e8e7c33 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -14,6 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #endregion + namespace MoreLinq.Test { using System.Collections.Generic; diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 0b5d3d7a9..3c11580ee 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -14,6 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #endregion + namespace MoreLinq { using System; From 3450a3f16d654f5e65aa057942ce306e99bc2626 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:20:04 -0500 Subject: [PATCH 19/51] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e9dd7d17..2a897f211 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,7 @@ This method has 2 overloads. ### Duplicates -Returns all duplicated elements of the given source, using the specified element equality comparer +Returns all duplicate elements of the given source. This method has 2 overloads. From c4b2b19587168efcdff173bcdaf1890fef6cc0ca Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:21:04 -0500 Subject: [PATCH 20/51] update doc with exception --- MoreLinq/Duplicates.cs | 1 + MoreLinq/Extensions.g.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 3c11580ee..1953ae024 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -28,6 +28,7 @@ static partial class MoreEnumerable /// source sequence. /// The type of the elements in the source sequence. /// all elements that are duplicated. + /// is null. public static IEnumerable Duplicates(this IEnumerable source) => Duplicates(source, null); /// diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 8edf326a2..a876fe2cc 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1294,6 +1294,7 @@ public static partial class DuplicatesExtension /// source sequence. /// The type of the elements in the source sequence. /// all elements that are duplicated. + /// is null. public static IEnumerable Duplicates(this IEnumerable source) => MoreEnumerable.Duplicates(source); /// From 551ff0463b67a619eae9651f7d1f727fae852367 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:21:32 -0500 Subject: [PATCH 21/51] rename test cases, fix type --- MoreLinq.Test/DuplicatesTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index b6e8e7c33..ee9813dd9 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -99,7 +99,7 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Compa } [Test] - public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_False_Comparer_Then_Then_Empty_Sequence_Is_Returned() + public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_False_Comparer_Then_Empty_Sequence_Is_Returned() { var stringArray = new[] { @@ -114,7 +114,7 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_False_Comp } [Test] - public void When_Asking_For_Duplicates_On_Multiple_Duplicates_Sequence_With_Custom_Always_False_Comparer_Then_Then_Empty_Sequence_Is_Returned() + public void When_Asking_For_Duplicates_On_Multiple_Duplicates_Sequence_With_Custom_Always_False_Comparer_Then_Empty_Sequence_Is_Returned() { var stringArray = new[] { From 9d4c2eee28f51c7a59ab6f057b8c86c0ef6e96d5 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:22:31 -0500 Subject: [PATCH 22/51] add blank after summary --- MoreLinq/Duplicates.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 1953ae024..3d7d31468 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -29,6 +29,7 @@ static partial class MoreEnumerable /// The type of the elements in the source sequence. /// all elements that are duplicated. /// is null. + public static IEnumerable Duplicates(this IEnumerable source) => Duplicates(source, null); /// @@ -40,6 +41,7 @@ static partial class MoreEnumerable /// Type of the source sequence /// all elements of the source sequence that are duplicated, based on the provided equality comparer /// is null. + public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) { if (source is null) throw new ArgumentNullException(nameof(source)); From 0e564e5b70f485efa53dba958587fea22c2b62c8 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:25:35 -0500 Subject: [PATCH 23/51] update doc and regen extension --- MoreLinq/Duplicates.cs | 8 +++++--- MoreLinq/Extensions.g.cs | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 3d7d31468..93bb75e1c 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -25,17 +25,19 @@ static partial class MoreEnumerable /// /// Returns all duplicated elements of the given source. /// - /// source sequence. + /// The source sequence. /// The type of the elements in the source sequence. /// all elements that are duplicated. /// is null. - public static IEnumerable Duplicates(this IEnumerable source) => Duplicates(source, null); + public static IEnumerable Duplicates(this IEnumerable source) => + Duplicates(source, null); + /// /// Returns all duplicated elements of the given source, using the specified element equality comparer /// - /// source sequence. + /// The source sequence. /// The equality comparer to use to determine whether or not keys are equal. /// If null, the default equality comparer for TSource is used. /// Type of the source sequence diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index a876fe2cc..77835f549 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1291,21 +1291,24 @@ public static partial class DuplicatesExtension /// /// Returns all duplicated elements of the given source. /// - /// source sequence. + /// The source sequence. /// The type of the elements in the source sequence. /// all elements that are duplicated. /// is null. + public static IEnumerable Duplicates(this IEnumerable source) => MoreEnumerable.Duplicates(source); + /// /// Returns all duplicated elements of the given source, using the specified element equality comparer /// - /// source sequence. + /// The source sequence. /// The equality comparer to use to determine whether or not keys are equal. /// If null, the default equality comparer for TSource is used. /// Type of the source sequence /// all elements of the source sequence that are duplicated, based on the provided equality comparer /// is null. + public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) => MoreEnumerable.Duplicates(source, comparer); From 6c29da400684f5489d298333048737765df4f2f7 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:26:02 -0500 Subject: [PATCH 24/51] update doc --- MoreLinq/Duplicates.cs | 4 ++-- MoreLinq/Extensions.g.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 93bb75e1c..bd1b048c8 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -23,7 +23,7 @@ namespace MoreLinq static partial class MoreEnumerable { /// - /// Returns all duplicated elements of the given source. + /// Returns all duplicate elements of the given source. /// /// The source sequence. /// The type of the elements in the source sequence. @@ -35,7 +35,7 @@ public static IEnumerable Duplicates(this IEnumerable source) => /// - /// Returns all duplicated elements of the given source, using the specified element equality comparer + /// Returns all duplicate elements of the given source, using the specified element equality comparer /// /// The source sequence. /// The equality comparer to use to determine whether or not keys are equal. diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 77835f549..93c72ec15 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1289,7 +1289,7 @@ public static IEnumerable DistinctBy(this IEnumerable - /// Returns all duplicated elements of the given source. + /// Returns all duplicate elements of the given source. /// /// The source sequence. /// The type of the elements in the source sequence. @@ -1300,7 +1300,7 @@ public static partial class DuplicatesExtension /// - /// Returns all duplicated elements of the given source, using the specified element equality comparer + /// Returns all duplicate elements of the given source, using the specified element equality comparer /// /// The source sequence. /// The equality comparer to use to determine whether or not keys are equal. From 9536cfa0aa8a18e96a3ecaf92be109973e36e2a0 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:33:12 -0500 Subject: [PATCH 25/51] use tsource, add remarks, and rewrite doc --- MoreLinq/Duplicates.cs | 21 ++++++++++++------- MoreLinq/Extensions.g.cs | 21 ++++++++++++------- .../PublicAPI/net6.0/PublicAPI.Unshipped.txt | 4 ++-- .../netstandard2.0/PublicAPI.Unshipped.txt | 4 ++-- .../netstandard2.1/PublicAPI.Unshipped.txt | 4 ++-- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index bd1b048c8..fbe666224 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -26,22 +26,27 @@ static partial class MoreEnumerable /// Returns all duplicate elements of the given source. /// /// The source sequence. - /// The type of the elements in the source sequence. - /// all elements that are duplicated. + /// The type of the elements in the source sequence. + /// All elements that are duplicated. + /// This operator uses deferred execution and streams its results. /// is null. - public static IEnumerable Duplicates(this IEnumerable source) => + public static IEnumerable Duplicates(this IEnumerable source) => Duplicates(source, null); /// - /// Returns all duplicate elements of the given source, using the specified element equality comparer + /// Returns all duplicate elements of the given source, using the specified equality + /// comparer. /// /// The source sequence. - /// The equality comparer to use to determine whether or not keys are equal. - /// If null, the default equality comparer for TSource is used. - /// Type of the source sequence - /// all elements of the source sequence that are duplicated, based on the provided equality comparer + /// + /// The equality comparer to use to determine whether one + /// equals another. If , the default equality comparer for + /// is used. + /// The type of the elements in the source sequence. + /// All elements of the source sequence that are duplicated, based on the provided equality comparer + /// This operator uses deferred execution and streams its results. /// is null. public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 93c72ec15..44117b885 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1292,21 +1292,26 @@ public static partial class DuplicatesExtension /// Returns all duplicate elements of the given source. /// /// The source sequence. - /// The type of the elements in the source sequence. - /// all elements that are duplicated. + /// The type of the elements in the source sequence. + /// All elements that are duplicated. + /// This operator uses deferred execution and streams its results. /// is null. - public static IEnumerable Duplicates(this IEnumerable source) => MoreEnumerable.Duplicates(source); + public static IEnumerable Duplicates(this IEnumerable source) => MoreEnumerable.Duplicates(source); /// - /// Returns all duplicate elements of the given source, using the specified element equality comparer + /// Returns all duplicate elements of the given source, using the specified equality + /// comparer. /// /// The source sequence. - /// The equality comparer to use to determine whether or not keys are equal. - /// If null, the default equality comparer for TSource is used. - /// Type of the source sequence - /// all elements of the source sequence that are duplicated, based on the provided equality comparer + /// + /// The equality comparer to use to determine whether one + /// equals another. If , the default equality comparer for + /// is used. + /// The type of the elements in the source sequence. + /// All elements of the source sequence that are duplicated, based on the provided equality comparer + /// This operator uses deferred execution and streams its results. /// is null. public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) diff --git a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt index aec636150..cada4690e 100644 --- a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt @@ -1,6 +1,6 @@ #nullable enable MoreLinq.Extensions.DuplicatesExtension -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index aec636150..cada4690e 100644 --- a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,6 +1,6 @@ #nullable enable MoreLinq.Extensions.DuplicatesExtension -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt index aec636150..cada4690e 100644 --- a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt @@ -1,6 +1,6 @@ #nullable enable MoreLinq.Extensions.DuplicatesExtension -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! From 85fe5970aa6e2769cdf80947a310981ae4665b5b Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:34:28 -0500 Subject: [PATCH 26/51] use same return summary in doc --- MoreLinq/Duplicates.cs | 2 +- MoreLinq/Extensions.g.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index fbe666224..f09fe9777 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -45,7 +45,7 @@ public static IEnumerable Duplicates(this IEnumerable /// equals another. If , the default equality comparer for /// is used. /// The type of the elements in the source sequence. - /// All elements of the source sequence that are duplicated, based on the provided equality comparer + /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. /// is null. diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 44117b885..28ce14022 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1310,7 +1310,7 @@ public static partial class DuplicatesExtension /// equals another. If , the default equality comparer for /// is used. /// The type of the elements in the source sequence. - /// All elements of the source sequence that are duplicated, based on the provided equality comparer + /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. /// is null. From f140e75744d2fa6f94f08b14b5ba923ad141201c Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:39:56 -0500 Subject: [PATCH 27/51] fix warns --- MoreLinq/Duplicates.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index f09fe9777..cc4959dd9 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -23,7 +23,7 @@ namespace MoreLinq static partial class MoreEnumerable { /// - /// Returns all duplicate elements of the given source. + /// Returns all duplicate elements of the given source. /// /// The source sequence. /// The type of the elements in the source sequence. @@ -34,10 +34,9 @@ static partial class MoreEnumerable public static IEnumerable Duplicates(this IEnumerable source) => Duplicates(source, null); - /// - /// Returns all duplicate elements of the given source, using the specified equality - /// comparer. + /// Returns all duplicate elements of the given source, using the specified equality + /// comparer. /// /// The source sequence. /// From 1741a49f42bd9a90a10c2bcec3503a756a04e64f Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:42:33 -0500 Subject: [PATCH 28/51] move exception doc higher up --- MoreLinq/Duplicates.cs | 4 ++-- MoreLinq/Extensions.g.cs | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index cc4959dd9..495c3a1fc 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -27,9 +27,9 @@ static partial class MoreEnumerable /// /// The source sequence. /// The type of the elements in the source sequence. + /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. - /// is null. public static IEnumerable Duplicates(this IEnumerable source) => Duplicates(source, null); @@ -44,9 +44,9 @@ public static IEnumerable Duplicates(this IEnumerable /// equals another. If , the default equality comparer for /// is used. /// The type of the elements in the source sequence. + /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. - /// is null. public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) { diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 28ce14022..db8e5f7f4 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1289,20 +1289,19 @@ public static IEnumerable DistinctBy(this IEnumerable - /// Returns all duplicate elements of the given source. + /// Returns all duplicate elements of the given source. /// /// The source sequence. /// The type of the elements in the source sequence. + /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. - /// is null. public static IEnumerable Duplicates(this IEnumerable source) => MoreEnumerable.Duplicates(source); - /// - /// Returns all duplicate elements of the given source, using the specified equality - /// comparer. + /// Returns all duplicate elements of the given source, using the specified equality + /// comparer. /// /// The source sequence. /// @@ -1310,9 +1309,9 @@ public static partial class DuplicatesExtension /// equals another. If , the default equality comparer for /// is used. /// The type of the elements in the source sequence. + /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. - /// is null. public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) => MoreEnumerable.Duplicates(source, comparer); From 63a6f6b48220949ded5ff18b43f9a553dfdacda2 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:49:11 -0500 Subject: [PATCH 29/51] try fixing warn --- MoreLinq/Duplicates.cs | 2 -- MoreLinq/Extensions.g.cs | 2 -- 2 files changed, 4 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 495c3a1fc..7c0485db0 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -30,7 +30,6 @@ static partial class MoreEnumerable /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. - public static IEnumerable Duplicates(this IEnumerable source) => Duplicates(source, null); @@ -47,7 +46,6 @@ public static IEnumerable Duplicates(this IEnumerable /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. - public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) { if (source is null) throw new ArgumentNullException(nameof(source)); diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index db8e5f7f4..6f15b2f99 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1296,7 +1296,6 @@ public static partial class DuplicatesExtension /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. - public static IEnumerable Duplicates(this IEnumerable source) => MoreEnumerable.Duplicates(source); /// @@ -1312,7 +1311,6 @@ public static partial class DuplicatesExtension /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. - public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) => MoreEnumerable.Duplicates(source, comparer); From ebfac514100a1c7554430df1065c85fb8034af88 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Wed, 15 Nov 2023 14:57:00 -0500 Subject: [PATCH 30/51] use testing sequence instead --- MoreLinq.Test/DuplicatesTest.cs | 50 +++++++++------------------------ 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index ee9813dd9..842fc17d7 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -32,14 +32,9 @@ public void Duplicates_IsLazy() [Test] public void When_Asking_For_Duplicates_On_Sequence_Without_Duplicates_Then_Empty_Sequence_Is_Returned() { - var stringArray = new[] - { - "FirstElement", - "SecondElement", - "ThirdElement" - }; + using var testingSequence = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); - var duplicates = stringArray.Duplicates(); + var duplicates = testingSequence.Duplicates(); Assert.That(duplicates, Is.Empty); } @@ -47,16 +42,15 @@ public void When_Asking_For_Duplicates_On_Sequence_Without_Duplicates_Then_Empty [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_Duplicates_Are_Returned() { - var stringArray = new[] - { + using var testingSequence = TestingSequence.Of( "FirstElement", "DUPLICATED_STRING", "DUPLICATED_STRING", "DUPLICATED_STRING", "ThirdElement" - }; + ); - var duplicates = stringArray.Duplicates().ToArray(); + var duplicates = testingSequence.Duplicates().ToArray(); Assert.That(duplicates, Contains.Item("DUPLICATED_STRING")); Assert.That(duplicates.AtMost(1), Is.True); @@ -65,8 +59,7 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_Duplicat [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Multiple_Duplicates_Then_Duplicates_Are_Returned() { - var stringArray = new[] - { + using var testingSequence = TestingSequence.Of( "FirstElement", "DUPLICATED_STRING", "DUPLICATED_STRING", @@ -74,9 +67,9 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Multiple_Duplicates_Then "ThirdElement", "SECOND_DUPLICATED_STRING", "SECOND_DUPLICATED_STRING" - }; + ); - var duplicates = stringArray.Duplicates().ToArray(); + var duplicates = testingSequence.Duplicates().ToArray(); Assert.That(duplicates, Contains.Item("DUPLICATED_STRING")); Assert.That(duplicates, Contains.Item("SECOND_DUPLICATED_STRING")); @@ -86,14 +79,9 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Multiple_Duplicates_Then [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Comparer_Then_Duplicates_Are_Returned() { - var stringArray = new[] - { - "FirstElement", - "SecondElement", - "ThirdElement" - }; + using var testingSequence = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); - var duplicates = stringArray.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); + var duplicates = testingSequence.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); Assert.That(duplicates.AtMost(1), Is.True); } @@ -101,14 +89,9 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Compa [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_False_Comparer_Then_Empty_Sequence_Is_Returned() { - var stringArray = new[] - { - "FirstElement", - "SecondElement", - "ThirdElement" - }; + using var testingSequence = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); - var duplicates = stringArray.Duplicates(new DummyStringAlwaysFalseComparer()); + var duplicates = testingSequence.Duplicates(new DummyStringAlwaysFalseComparer()); Assert.That(duplicates, Is.Empty); } @@ -116,14 +99,9 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_False_Comp [Test] public void When_Asking_For_Duplicates_On_Multiple_Duplicates_Sequence_With_Custom_Always_False_Comparer_Then_Empty_Sequence_Is_Returned() { - var stringArray = new[] - { - "DUPLICATED_STRING", - "DUPLICATED_STRING", - "DUPLICATED_STRING" - }; + using var testingSequence = TestingSequence.Of("DUPLICATED_STRING", "DUPLICATED_STRING", "DUPLICATED_STRING"); - var duplicates = stringArray.Duplicates(new DummyStringAlwaysFalseComparer()); + var duplicates = testingSequence.Duplicates(new DummyStringAlwaysFalseComparer()); Assert.That(duplicates, Is.Empty); } From 553ed630feeff230059a71d5d7be9697f998ca36 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Thu, 16 Nov 2023 05:49:20 -0500 Subject: [PATCH 31/51] add empty line, ignoring CodeFactor --- MoreLinq/Duplicates.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 7c0485db0..495c3a1fc 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -30,6 +30,7 @@ static partial class MoreEnumerable /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. + public static IEnumerable Duplicates(this IEnumerable source) => Duplicates(source, null); @@ -46,6 +47,7 @@ public static IEnumerable Duplicates(this IEnumerable /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. + public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) { if (source is null) throw new ArgumentNullException(nameof(source)); From 865949d60244982b47f446821c0259639a37ed3b Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Thu, 16 Nov 2023 18:16:14 -0500 Subject: [PATCH 32/51] add streaming test, code from atifaziz --- MoreLinq.Test/DuplicatesTest.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index 842fc17d7..999fc29ac 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -29,6 +29,23 @@ public void Duplicates_IsLazy() _ = new BreakingSequence().Duplicates(); } + [Test] + public void Streams_Duplicates_As_They_Are_Discovered() + { + static IEnumerable Source() + { + yield return "DUPLICATED_STRING"; + yield return "DUPLICATED_STRING"; + throw new TestException(); + } + + using var source = TestingSequence.Of(Source()); + + void Act() => source.Duplicates().Take(1); + + Assert.That(Act, Throws.Nothing); + } + [Test] public void When_Asking_For_Duplicates_On_Sequence_Without_Duplicates_Then_Empty_Sequence_Is_Returned() { From 4ed9543c8892f03ab6e662050af5036a57789aea Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Thu, 16 Nov 2023 20:09:16 -0500 Subject: [PATCH 33/51] use scanby dry --- MoreLinq/Duplicates.cs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 495c3a1fc..0aed90597 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -19,6 +19,7 @@ namespace MoreLinq { using System; using System.Collections.Generic; + using System.Linq; static partial class MoreEnumerable { @@ -52,20 +53,12 @@ public static IEnumerable Duplicates(this IEnumerable { if (source is null) throw new ArgumentNullException(nameof(source)); - return GetDuplicates(); - - IEnumerable GetDuplicates() - { - var keySet = new HashSet(comparer); - var yieldSet = new HashSet(comparer); - foreach (var element in source) - { - if (!keySet.Add(element) && yieldSet.Add(element)) - { - yield return element; - } - } - } + return from e in source.ScanBy(static e => e, + static _ => 0, + static (count, _, _) => unchecked(Math.Min(count + 1, 3)), + comparer) + where e.Value is 2 + select e.Key; } } } From 83abfc5115a94a0e22cae9de79693d6fccfa433c Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Thu, 16 Nov 2023 20:09:54 -0500 Subject: [PATCH 34/51] regen build --- MoreLinq/Extensions.g.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 6f15b2f99..db8e5f7f4 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1296,6 +1296,7 @@ public static partial class DuplicatesExtension /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. + public static IEnumerable Duplicates(this IEnumerable source) => MoreEnumerable.Duplicates(source); /// @@ -1311,6 +1312,7 @@ public static partial class DuplicatesExtension /// is null. /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. + public static IEnumerable Duplicates(this IEnumerable source, IEqualityComparer? comparer) => MoreEnumerable.Duplicates(source, comparer); From bd1c3045cb32274f3d5ec50b96b05696d7a90194 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Wed, 15 Nov 2023 23:11:35 +0100 Subject: [PATCH 35/51] Set package validation baseline to version 4.0 --- MoreLinq/CompatibilitySuppressions.xml | 208 +++---------------------- MoreLinq/MoreLinq.csproj | 2 +- 2 files changed, 21 insertions(+), 189 deletions(-) diff --git a/MoreLinq/CompatibilitySuppressions.xml b/MoreLinq/CompatibilitySuppressions.xml index ead8c1613..ffe9243dc 100644 --- a/MoreLinq/CompatibilitySuppressions.xml +++ b/MoreLinq/CompatibilitySuppressions.xml @@ -1,232 +1,64 @@ - - CP0001 - T:MoreLinq.Extensions.AppendExtension - lib/net462/MoreLinq.dll - lib/netstandard2.0/MoreLinq.dll - true - - - CP0001 - T:MoreLinq.Extensions.PrependExtension - lib/net462/MoreLinq.dll - lib/netstandard2.0/MoreLinq.dll - true - - - CP0001 - T:MoreLinq.Extensions.AppendExtension - lib/net6.0/MoreLinq.dll - lib/net6.0/MoreLinq.dll - true - - - CP0001 - T:MoreLinq.Extensions.PrependExtension - lib/net6.0/MoreLinq.dll - lib/net6.0/MoreLinq.dll - true - - - CP0001 - T:MoreLinq.Extensions.AppendExtension - lib/netstandard2.0/MoreLinq.dll - lib/netstandard2.0/MoreLinq.dll - true - - - CP0001 - T:MoreLinq.Extensions.PrependExtension - lib/netstandard2.0/MoreLinq.dll - lib/netstandard2.0/MoreLinq.dll - true - - - CP0001 - T:MoreLinq.Extensions.AppendExtension - lib/netstandard2.1/MoreLinq.dll - lib/netstandard2.1/MoreLinq.dll - true - - - CP0001 - T:MoreLinq.Extensions.PrependExtension - lib/netstandard2.1/MoreLinq.dll - 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) - lib/net462/MoreLinq.dll - 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) - lib/net462/MoreLinq.dll - lib/netstandard2.0/MoreLinq.dll - true - - - CP0002 - M:MoreLinq.MoreEnumerable.Prepend``1(System.Collections.Generic.IEnumerable{``0},``0) - lib/net462/MoreLinq.dll - lib/netstandard2.0/MoreLinq.dll - true - - - CP0002 - M:MoreLinq.MoreEnumerable.Windowed``1(System.Collections.Generic.IEnumerable{``0},System.Int32) - lib/net462/MoreLinq.dll - 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) - lib/net6.0/MoreLinq.dll - 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) - lib/net6.0/MoreLinq.dll - lib/net6.0/MoreLinq.dll - true - - - CP0002 - M:MoreLinq.MoreEnumerable.Prepend``1(System.Collections.Generic.IEnumerable{``0},``0) - lib/net6.0/MoreLinq.dll - lib/net6.0/MoreLinq.dll - true - - - CP0002 - M:MoreLinq.MoreEnumerable.Windowed``1(System.Collections.Generic.IEnumerable{``0},System.Int32) - lib/net6.0/MoreLinq.dll - 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) - lib/netstandard2.0/MoreLinq.dll - 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}) + M:MoreLinq.MoreEnumerable.SkipLast``1(System.Collections.Generic.IEnumerable{``0},System.Int32) lib/netstandard2.0/MoreLinq.dll - lib/netstandard2.0/MoreLinq.dll - true + lib/netstandard2.1/MoreLinq.dll CP0002 - M:MoreLinq.MoreEnumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},``0) + M:MoreLinq.MoreEnumerable.TakeLast``1(System.Collections.Generic.IEnumerable{``0},System.Int32) lib/netstandard2.0/MoreLinq.dll - lib/netstandard2.0/MoreLinq.dll - true + lib/netstandard2.1/MoreLinq.dll CP0002 - M:MoreLinq.MoreEnumerable.Prepend``1(System.Collections.Generic.IEnumerable{``0},``0) + M:MoreLinq.MoreEnumerable.ToHashSet``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEqualityComparer{``0}) lib/netstandard2.0/MoreLinq.dll - lib/netstandard2.0/MoreLinq.dll - true + lib/netstandard2.1/MoreLinq.dll CP0002 - M:MoreLinq.MoreEnumerable.Windowed``1(System.Collections.Generic.IEnumerable{``0},System.Int32) + M:MoreLinq.MoreEnumerable.ToHashSet``1(System.Collections.Generic.IEnumerable{``0}) lib/netstandard2.0/MoreLinq.dll - lib/netstandard2.0/MoreLinq.dll - true + lib/netstandard2.1/MoreLinq.dll CP0002 - M:MoreLinq.Extensions.BatchExtension.Batch``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{System.Collections.Generic.IEnumerable{``0},``1}) + M:MoreLinq.MoreEnumerable.DistinctBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IEqualityComparer{``1}) lib/netstandard2.1/MoreLinq.dll - lib/netstandard2.1/MoreLinq.dll - true + lib/net6.0/MoreLinq.dll CP0002 - M:MoreLinq.MoreEnumerable.Append``1(System.Collections.Generic.IEnumerable{``0},``0) + M:MoreLinq.MoreEnumerable.DistinctBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1}) lib/netstandard2.1/MoreLinq.dll - lib/netstandard2.1/MoreLinq.dll - true + lib/net6.0/MoreLinq.dll CP0002 - M:MoreLinq.MoreEnumerable.Batch``2(System.Collections.Generic.IEnumerable{``0},System.Int32,System.Func{System.Collections.Generic.IEnumerable{``0},``1}) + M:MoreLinq.MoreEnumerable.MaxBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1}) lib/netstandard2.1/MoreLinq.dll - lib/netstandard2.1/MoreLinq.dll - true + lib/net6.0/MoreLinq.dll CP0002 - M:MoreLinq.MoreEnumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},``0) + M:MoreLinq.MoreEnumerable.MaxBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1}) lib/netstandard2.1/MoreLinq.dll - lib/netstandard2.1/MoreLinq.dll - true + lib/net6.0/MoreLinq.dll CP0002 - M:MoreLinq.MoreEnumerable.Prepend``1(System.Collections.Generic.IEnumerable{``0},``0) + M:MoreLinq.MoreEnumerable.MinBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1}) lib/netstandard2.1/MoreLinq.dll - lib/netstandard2.1/MoreLinq.dll - true + lib/net6.0/MoreLinq.dll CP0002 - M:MoreLinq.MoreEnumerable.Windowed``1(System.Collections.Generic.IEnumerable{``0},System.Int32) + M:MoreLinq.MoreEnumerable.MinBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1}) lib/netstandard2.1/MoreLinq.dll - lib/netstandard2.1/MoreLinq.dll - true - - - PKV006 - .NETStandard,Version=v1.0 + lib/net6.0/MoreLinq.dll diff --git a/MoreLinq/MoreLinq.csproj b/MoreLinq/MoreLinq.csproj index 3ca59d89d..9ea6c3410 100644 --- a/MoreLinq/MoreLinq.csproj +++ b/MoreLinq/MoreLinq.csproj @@ -136,7 +136,7 @@ ..\dist README.md true - 3.4.1 + 4.0.0 true true true From 22119eec7263f05d4c40c741d6c342c31cc9774a Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 16 Nov 2023 23:04:27 +0100 Subject: [PATCH 36/51] Use .NET 8 SDK to add .NET 8 target This is a squashed merge of PR #1041. --------- Co-authored-by: Stuart Turner --- .editorconfig | 12 + Directory.Build.props | 2 +- MoreLinq.Test/.editorconfig | 3 + MoreLinq.Test/Make.cs | 30 + MoreLinq.Test/MemoizeTest.cs | 2 +- MoreLinq.Test/MoreLinq.Test.csproj | 2 +- MoreLinq.Test/OrderedMergeTest.cs | 2 - MoreLinq.Test/SegmentTest.cs | 2 - MoreLinq.Test/SliceTest.cs | 14 +- MoreLinq.Test/ZipLongestTest.cs | 8 +- MoreLinq/CompatibilitySuppressions.xml | 6 + MoreLinq/Experimental/Async/Merge.cs | 4 + MoreLinq/Experimental/Await.cs | 2 + MoreLinq/Flatten.cs | 3 +- MoreLinq/GroupAdjacent.cs | 2 +- MoreLinq/MoreLinq.csproj | 2 +- MoreLinq/Permutations.cs | 4 +- .../PublicAPI/net8.0/PublicAPI.Shipped.txt | 1 + .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 691 ++++++++++++++++++ MoreLinq/RandomSubset.cs | 3 + MoreLinq/SequenceException.cs | 18 +- MoreLinq/UnreachableException.cs | 8 +- appveyor.yml | 2 + .../MoreLinq.ExtensionsGenerator.csproj | 4 +- global.json | 2 +- test.cmd | 2 + test.sh | 2 +- 27 files changed, 802 insertions(+), 31 deletions(-) create mode 100644 MoreLinq.Test/Make.cs create mode 100644 MoreLinq/PublicAPI/net8.0/PublicAPI.Shipped.txt create mode 100644 MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt diff --git a/.editorconfig b/.editorconfig index 57e440765..bf62f14a8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -86,3 +86,15 @@ dotnet_diagnostic.IDE0055.severity = suggestion # IDE0046: Convert to conditional expression dotnet_diagnostic.IDE0046.severity = suggestion + +# CA1510: Use 'ArgumentNullException.ThrowIfNull' instead of explicitly throwing a new exception instance +# TODO: Remove post https://github.com/morelinq/MoreLINQ/issues/903 +dotnet_diagnostic.CA1510.severity = suggestion + +# CA1512: Use 'ArgumentOutOfRangeException.ThrowIfNegativeOrZero' instead of explicitly throwing a new exception instance +# TODO: Remove post https://github.com/morelinq/MoreLINQ/issues/903 +dotnet_diagnostic.CA1512.severity = suggestion + +# CA1513: Use 'ObjectDisposedException.ThrowIf' instead of explicitly throwing a new exception instance +# TODO: Remove post https://github.com/morelinq/MoreLINQ/issues/903 +dotnet_diagnostic.CA1513.severity = suggestion diff --git a/Directory.Build.props b/Directory.Build.props index ef2ed08ed..9fc11a600 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,7 +3,7 @@ 11 enable true - 7.0-all + 8.0-all true EnableGenerateDocumentationFile diff --git a/MoreLinq.Test/.editorconfig b/MoreLinq.Test/.editorconfig index ffc9fb911..e6073bfb4 100644 --- a/MoreLinq.Test/.editorconfig +++ b/MoreLinq.Test/.editorconfig @@ -35,6 +35,9 @@ dotnet_diagnostic.IDE0047.severity = suggestion [*{Test,Tests}.cs] +# CA1861: Avoid constant arrays as arguments +dotnet_diagnostic.CA1861.severity = none + # IDE0022: Use expression/block body for methods dotnet_diagnostic.IDE0022.severity = none diff --git a/MoreLinq.Test/Make.cs b/MoreLinq.Test/Make.cs new file mode 100644 index 000000000..23e4cf873 --- /dev/null +++ b/MoreLinq.Test/Make.cs @@ -0,0 +1,30 @@ +#region License and Terms +// MoreLINQ - Extensions to LINQ to Objects +// Copyright (c) 2018 Atif Aziz. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion + +global using static MoreLinq.Test.Make; + +namespace MoreLinq.Test +{ + using System.Collections.Generic; + + static class Make + { + public static IEnumerable Seq(params T[] values) => + from value in values + select value; + } +} diff --git a/MoreLinq.Test/MemoizeTest.cs b/MoreLinq.Test/MemoizeTest.cs index 31ce2aeca..f8280e052 100644 --- a/MoreLinq.Test/MemoizeTest.cs +++ b/MoreLinq.Test/MemoizeTest.cs @@ -217,7 +217,7 @@ void Run() [Test] public static void MemoizeIteratorThrowsWhenCacheDisposedDuringIteration() { - var sequence = Enumerable.Range(1, 10); + var sequence = Seq(1, 2, 3); var memoized = sequence.Memoize(); var disposable = (IDisposable)memoized; diff --git a/MoreLinq.Test/MoreLinq.Test.csproj b/MoreLinq.Test/MoreLinq.Test.csproj index c30b247bb..0b6d42855 100644 --- a/MoreLinq.Test/MoreLinq.Test.csproj +++ b/MoreLinq.Test/MoreLinq.Test.csproj @@ -2,7 +2,7 @@ MoreLinq.Test - net7.0;net6.0;net471 + net8.0;net7.0;net6.0;net471 portable MoreLinq.Test Exe diff --git a/MoreLinq.Test/OrderedMergeTest.cs b/MoreLinq.Test/OrderedMergeTest.cs index 416e43c48..6efcc9574 100644 --- a/MoreLinq.Test/OrderedMergeTest.cs +++ b/MoreLinq.Test/OrderedMergeTest.cs @@ -24,8 +24,6 @@ namespace MoreLinq.Test [TestFixture] public class OrderedMergeTest { - static IEnumerable Seq(params T[] values) => values; - public static readonly IEnumerable TestData = from e in new[] { diff --git a/MoreLinq.Test/SegmentTest.cs b/MoreLinq.Test/SegmentTest.cs index e4b587120..0f8996d86 100644 --- a/MoreLinq.Test/SegmentTest.cs +++ b/MoreLinq.Test/SegmentTest.cs @@ -149,8 +149,6 @@ public void VerifyCanSegmentByPrevious() Assert.That(result.All(s => s.Count() == repCount), Is.True); } - static IEnumerable Seq(params T[] values) => values; - public static readonly IEnumerable TestData = from e in new[] { diff --git a/MoreLinq.Test/SliceTest.cs b/MoreLinq.Test/SliceTest.cs index d7498b946..f6b459f82 100644 --- a/MoreLinq.Test/SliceTest.cs +++ b/MoreLinq.Test/SliceTest.cs @@ -45,7 +45,7 @@ public void TestSliceIdentity() { const int count = 100; var sequenceA = Enumerable.Range(1, count); - var sequenceB = sequenceA.ToList(); + var sequenceB = sequenceA.ToList().AsEnumerable(); var resultA = sequenceA.Slice(0, count); var resultB = sequenceB.Slice(0, count); @@ -64,7 +64,8 @@ public void TestSliceFirstItem() { const int count = 10; var sequenceA = Enumerable.Range(1, count); - var sequenceB = sequenceA.ToList(); + var sequenceB = sequenceA.ToList().AsEnumerable(); + var resultA = sequenceA.Slice(0, 1); var resultB = sequenceB.Slice(0, 1); @@ -82,7 +83,8 @@ public void TestSliceLastItem() { const int count = 10; var sequenceA = Enumerable.Range(1, count); - var sequenceB = sequenceA.ToList(); + var sequenceB = sequenceA.ToList().AsEnumerable(); + var resultA = sequenceA.Slice(count - 1, 1); var resultB = sequenceB.Slice(count - 1, 1); @@ -101,7 +103,8 @@ public void TestSliceSmallerThanSequence() { const int count = 10; var sequenceA = Enumerable.Range(1, count); - var sequenceB = sequenceA.ToList(); + var sequenceB = sequenceA.ToList().AsEnumerable(); + var resultA = sequenceA.Slice(4, 5); var resultB = sequenceB.Slice(4, 5); @@ -120,7 +123,8 @@ public void TestSliceLongerThanSequence() { const int count = 100; var sequenceA = Enumerable.Range(1, count); - var sequenceB = sequenceA.ToList(); + var sequenceB = sequenceA.ToList().AsEnumerable(); + var resultA = sequenceA.Slice(count / 2, count); var resultB = sequenceB.Slice(count / 2, count); diff --git a/MoreLinq.Test/ZipLongestTest.cs b/MoreLinq.Test/ZipLongestTest.cs index 3d07993a5..6ead0148e 100644 --- a/MoreLinq.Test/ZipLongestTest.cs +++ b/MoreLinq.Test/ZipLongestTest.cs @@ -26,8 +26,6 @@ namespace MoreLinq.Test [TestFixture] public class ZipLongestTest { - static IEnumerable Seq(params T[] values) => values; - public static readonly IEnumerable TestData = from e in new[] { @@ -44,10 +42,10 @@ from e in new[] [Test, TestCaseSource(nameof(TestData))] - public IEnumerable<(int, string)> ZipLongest(int[] first, string[] second) + public IEnumerable<(int, string)> ZipLongest(IEnumerable first, IEnumerable second) { - using var ts1 = TestingSequence.Of(first); - using var ts2 = TestingSequence.Of(second); + using var ts1 = first.AsTestingSequence(); + using var ts2 = second.AsTestingSequence(); return ts1.ZipLongest(ts2, Tuple.Create).ToArray(); } diff --git a/MoreLinq/CompatibilitySuppressions.xml b/MoreLinq/CompatibilitySuppressions.xml index ffe9243dc..1b532b5f8 100644 --- a/MoreLinq/CompatibilitySuppressions.xml +++ b/MoreLinq/CompatibilitySuppressions.xml @@ -1,6 +1,12 @@ + + CP0002 + M:MoreLinq.SequenceException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext) + lib/net6.0/MoreLinq.dll + lib/net8.0/MoreLinq.dll + CP0002 M:MoreLinq.MoreEnumerable.SkipLast``1(System.Collections.Generic.IEnumerable{``0},System.Int32) diff --git a/MoreLinq/Experimental/Async/Merge.cs b/MoreLinq/Experimental/Async/Merge.cs index 34130abef..7e6312b9b 100644 --- a/MoreLinq/Experimental/Async/Merge.cs +++ b/MoreLinq/Experimental/Async/Merge.cs @@ -180,7 +180,11 @@ async IAsyncEnumerable Async([EnumeratorCancellation]CancellationToken cancel // Signal cancellation to those in flight. Unfortunately, this relies on all // iterators to honour the cancellation. +#if NET8_0_OR_GREATER + await thisCancellationTokenSource.CancelAsync().ConfigureAwait(false); +#else thisCancellationTokenSource.Cancel(); +#endif // > The caller of an async-iterator method should only call `DisposeAsync()` // > when the method completed or was suspended by a `yield return`. diff --git a/MoreLinq/Experimental/Await.cs b/MoreLinq/Experimental/Await.cs index aa6e0a15f..abbfa0caa 100644 --- a/MoreLinq/Experimental/Await.cs +++ b/MoreLinq/Experimental/Await.cs @@ -697,7 +697,9 @@ await concurrencyGate.EnterAsync(cancellationToken) static class AwaitQuery { public static IAwaitQuery +#pragma warning disable CA1859 // Use concrete types when possible for improved performance (by-design) Create( +#pragma warning restore CA1859 // Use concrete types when possible for improved performance Func> impl, AwaitQueryOptions? options = null) => new AwaitQuery(impl, options); diff --git a/MoreLinq/Flatten.cs b/MoreLinq/Flatten.cs index 564da9731..eaee331d2 100644 --- a/MoreLinq/Flatten.cs +++ b/MoreLinq/Flatten.cs @@ -20,7 +20,6 @@ namespace MoreLinq { using System; - using System.Linq; using System.Collections; using System.Collections.Generic; @@ -135,7 +134,7 @@ public static IEnumerable< try { - while (stack.Any()) + while (stack.Count > 0) { e = stack.Pop(); diff --git a/MoreLinq/GroupAdjacent.cs b/MoreLinq/GroupAdjacent.cs index a79e58499..8cf89a5e3 100644 --- a/MoreLinq/GroupAdjacent.cs +++ b/MoreLinq/GroupAdjacent.cs @@ -295,7 +295,7 @@ static IEnumerable GroupAdjacentImpl( } } - static IGrouping CreateGroupAdjacentGrouping(TKey key, IList members) => + static Grouping CreateGroupAdjacentGrouping(TKey key, IList members) => Grouping.Create(key, members.IsReadOnly ? members : new ReadOnlyCollection(members)); static class Grouping diff --git a/MoreLinq/MoreLinq.csproj b/MoreLinq/MoreLinq.csproj index 9ea6c3410..38d48eee5 100644 --- a/MoreLinq/MoreLinq.csproj +++ b/MoreLinq/MoreLinq.csproj @@ -121,7 +121,7 @@ en-US 4.1.0 MoreLINQ Developers. - netstandard2.0;netstandard2.1;net6.0 + netstandard2.0;netstandard2.1;net6.0;net8.0 portable true MoreLinq diff --git a/MoreLinq/Permutations.cs b/MoreLinq/Permutations.cs index 52e354c60..f6cb840c4 100644 --- a/MoreLinq/Permutations.cs +++ b/MoreLinq/Permutations.cs @@ -167,8 +167,8 @@ void NextPermutation() /// be surprised to discover that all of the permutations looked the /// same. /// - /// List of permuted source sequence values - IList PermuteValueSet() + /// Array of permuted source sequence values + T[] PermuteValueSet() { var permutedSet = new T[_permutation.Length]; for (var i = 0; i < _permutation.Length; i++) diff --git a/MoreLinq/PublicAPI/net8.0/PublicAPI.Shipped.txt b/MoreLinq/PublicAPI/net8.0/PublicAPI.Shipped.txt new file mode 100644 index 000000000..7dc5c5811 --- /dev/null +++ b/MoreLinq/PublicAPI/net8.0/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt new file mode 100644 index 000000000..ce7910980 --- /dev/null +++ b/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -0,0 +1,691 @@ +#nullable enable +MoreLinq.Experimental.Async.ExperimentalEnumerable +MoreLinq.Experimental.AwaitQueryOptions +MoreLinq.Experimental.AwaitQueryOptions.MaxConcurrency.get -> int? +MoreLinq.Experimental.AwaitQueryOptions.PreserveOrder.get -> bool +MoreLinq.Experimental.AwaitQueryOptions.Scheduler.get -> System.Threading.Tasks.TaskScheduler! +MoreLinq.Experimental.AwaitQueryOptions.WithMaxConcurrency(int? value) -> MoreLinq.Experimental.AwaitQueryOptions! +MoreLinq.Experimental.AwaitQueryOptions.WithPreserveOrder(bool value) -> MoreLinq.Experimental.AwaitQueryOptions! +MoreLinq.Experimental.AwaitQueryOptions.WithScheduler(System.Threading.Tasks.TaskScheduler! value) -> MoreLinq.Experimental.AwaitQueryOptions! +MoreLinq.Experimental.ExperimentalEnumerable +MoreLinq.Experimental.IAwaitQuery +MoreLinq.Experimental.IAwaitQuery.Options.get -> MoreLinq.Experimental.AwaitQueryOptions! +MoreLinq.Experimental.IAwaitQuery.WithOptions(MoreLinq.Experimental.AwaitQueryOptions! options) -> MoreLinq.Experimental.IAwaitQuery! +MoreLinq.Experimental.ICurrentBuffer +MoreLinq.Extensions.AcquireExtension +MoreLinq.Extensions.AggregateExtension +MoreLinq.Extensions.AggregateRightExtension +MoreLinq.Extensions.AppendExtension +MoreLinq.Extensions.AssertCountExtension +MoreLinq.Extensions.AssertExtension +MoreLinq.Extensions.AtLeastExtension +MoreLinq.Extensions.AtMostExtension +MoreLinq.Extensions.BacksertExtension +MoreLinq.Extensions.BatchExtension +MoreLinq.Extensions.CartesianExtension +MoreLinq.Extensions.ChooseExtension +MoreLinq.Extensions.CompareCountExtension +MoreLinq.Extensions.ConsumeExtension +MoreLinq.Extensions.CountBetweenExtension +MoreLinq.Extensions.CountByExtension +MoreLinq.Extensions.CountDownExtension +MoreLinq.Extensions.DistinctByExtension +MoreLinq.Extensions.EndsWithExtension +MoreLinq.Extensions.EquiZipExtension +MoreLinq.Extensions.EvaluateExtension +MoreLinq.Extensions.ExactlyExtension +MoreLinq.Extensions.ExceptByExtension +MoreLinq.Extensions.ExcludeExtension +MoreLinq.Extensions.FallbackIfEmptyExtension +MoreLinq.Extensions.FillBackwardExtension +MoreLinq.Extensions.FillForwardExtension +MoreLinq.Extensions.FirstExtension +MoreLinq.Extensions.FirstOrDefaultExtension +MoreLinq.Extensions.FlattenExtension +MoreLinq.Extensions.FoldExtension +MoreLinq.Extensions.ForEachExtension +MoreLinq.Extensions.FullGroupJoinExtension +MoreLinq.Extensions.FullJoinExtension +MoreLinq.Extensions.GroupAdjacentExtension +MoreLinq.Extensions.IndexByExtension +MoreLinq.Extensions.IndexExtension +MoreLinq.Extensions.InsertExtension +MoreLinq.Extensions.InterleaveExtension +MoreLinq.Extensions.LagExtension +MoreLinq.Extensions.LastExtension +MoreLinq.Extensions.LastOrDefaultExtension +MoreLinq.Extensions.LeadExtension +MoreLinq.Extensions.LeftJoinExtension +MoreLinq.Extensions.MaxByExtension +MoreLinq.Extensions.MinByExtension +MoreLinq.Extensions.MaximaExtension +MoreLinq.Extensions.MinimaExtension +MoreLinq.Extensions.MoveExtension +MoreLinq.Extensions.OrderByExtension +MoreLinq.Extensions.OrderedMergeExtension +MoreLinq.Extensions.PadExtension +MoreLinq.Extensions.PadStartExtension +MoreLinq.Extensions.PairwiseExtension +MoreLinq.Extensions.PartialSortByExtension +MoreLinq.Extensions.PartialSortExtension +MoreLinq.Extensions.PartitionExtension +MoreLinq.Extensions.PermutationsExtension +MoreLinq.Extensions.PipeExtension +MoreLinq.Extensions.PrependExtension +MoreLinq.Extensions.PreScanExtension +MoreLinq.Extensions.RandomSubsetExtension +MoreLinq.Extensions.RankByExtension +MoreLinq.Extensions.RankExtension +MoreLinq.Extensions.RepeatExtension +MoreLinq.Extensions.RightJoinExtension +MoreLinq.Extensions.RunLengthEncodeExtension +MoreLinq.Extensions.ScanByExtension +MoreLinq.Extensions.ScanExtension +MoreLinq.Extensions.ScanRightExtension +MoreLinq.Extensions.SegmentExtension +MoreLinq.Extensions.ShuffleExtension +MoreLinq.Extensions.SingleExtension +MoreLinq.Extensions.SingleOrDefaultExtension +MoreLinq.Extensions.SkipLastExtension +MoreLinq.Extensions.SkipUntilExtension +MoreLinq.Extensions.SliceExtension +MoreLinq.Extensions.SortedMergeExtension +MoreLinq.Extensions.SplitExtension +MoreLinq.Extensions.StartsWithExtension +MoreLinq.Extensions.SubsetsExtension +MoreLinq.Extensions.TagFirstLastExtension +MoreLinq.Extensions.TakeEveryExtension +MoreLinq.Extensions.TakeLastExtension +MoreLinq.Extensions.TakeUntilExtension +MoreLinq.Extensions.ThenByExtension +MoreLinq.Extensions.ToArrayByIndexExtension +MoreLinq.Extensions.ToDataTableExtension +MoreLinq.Extensions.ToDelimitedStringExtension +MoreLinq.Extensions.ToDictionaryExtension +MoreLinq.Extensions.ToHashSetExtension +MoreLinq.Extensions.ToLookupExtension +MoreLinq.Extensions.TraceExtension +MoreLinq.Extensions.TransposeExtension +MoreLinq.Extensions.WindowExtension +MoreLinq.Extensions.WindowLeftExtension +MoreLinq.Extensions.WindowRightExtension +MoreLinq.Extensions.ZipLongestExtension +MoreLinq.Extensions.ZipShortestExtension +MoreLinq.IExtremaEnumerable +MoreLinq.IExtremaEnumerable.Take(int count) -> System.Collections.Generic.IEnumerable! +MoreLinq.IExtremaEnumerable.TakeLast(int count) -> System.Collections.Generic.IEnumerable! +MoreLinq.MoreEnumerable +MoreLinq.OrderByDirection +MoreLinq.OrderByDirection.Ascending = 0 -> MoreLinq.OrderByDirection +MoreLinq.OrderByDirection.Descending = 1 -> MoreLinq.OrderByDirection +MoreLinq.SequenceException +MoreLinq.SequenceException.SequenceException() -> void +MoreLinq.SequenceException.SequenceException(string? message) -> void +MoreLinq.SequenceException.SequenceException(string? message, System.Exception? innerException) -> void +static MoreLinq.Experimental.Async.ExperimentalEnumerable.Merge(this System.Collections.Generic.IEnumerable!>! sources) -> System.Collections.Generic.IAsyncEnumerable! +static MoreLinq.Experimental.Async.ExperimentalEnumerable.Merge(this System.Collections.Generic.IEnumerable!>! sources, int maxConcurrent) -> System.Collections.Generic.IAsyncEnumerable! +static MoreLinq.Experimental.ExperimentalEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, System.Func!, System.IObservable!>! accumulator1, System.Func!, System.IObservable!>! accumulator2, System.Func!, System.IObservable!>! accumulator3, System.Func!, System.IObservable!>! accumulator4, System.Func!, System.IObservable!>! accumulator5, System.Func!, System.IObservable!>! accumulator6, System.Func!, System.IObservable!>! accumulator7, System.Func!, System.IObservable!>! accumulator8, System.Func! resultSelector) -> TResult +static MoreLinq.Experimental.ExperimentalEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, System.Func!, System.IObservable!>! accumulator1, System.Func!, System.IObservable!>! accumulator2, System.Func!, System.IObservable!>! accumulator3, System.Func!, System.IObservable!>! accumulator4, System.Func!, System.IObservable!>! accumulator5, System.Func!, System.IObservable!>! accumulator6, System.Func!, System.IObservable!>! accumulator7, System.Func! resultSelector) -> TResult +static MoreLinq.Experimental.ExperimentalEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, System.Func!, System.IObservable!>! accumulator1, System.Func!, System.IObservable!>! accumulator2, System.Func!, System.IObservable!>! accumulator3, System.Func!, System.IObservable!>! accumulator4, System.Func!, System.IObservable!>! accumulator5, System.Func!, System.IObservable!>! accumulator6, System.Func! resultSelector) -> TResult +static MoreLinq.Experimental.ExperimentalEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, System.Func!, System.IObservable!>! accumulator1, System.Func!, System.IObservable!>! accumulator2, System.Func!, System.IObservable!>! accumulator3, System.Func!, System.IObservable!>! accumulator4, System.Func!, System.IObservable!>! accumulator5, System.Func! resultSelector) -> TResult +static MoreLinq.Experimental.ExperimentalEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, System.Func!, System.IObservable!>! accumulator1, System.Func!, System.IObservable!>! accumulator2, System.Func!, System.IObservable!>! accumulator3, System.Func!, System.IObservable!>! accumulator4, System.Func! resultSelector) -> TResult +static MoreLinq.Experimental.ExperimentalEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, System.Func!, System.IObservable!>! accumulator1, System.Func!, System.IObservable!>! accumulator2, System.Func!, System.IObservable!>! accumulator3, System.Func! resultSelector) -> TResult +static MoreLinq.Experimental.ExperimentalEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, System.Func!, System.IObservable!>! accumulator1, System.Func!, System.IObservable!>! accumulator2, System.Func! resultSelector) -> TResult +static MoreLinq.Experimental.ExperimentalEnumerable.AsOrdered(this MoreLinq.Experimental.IAwaitQuery! source) -> MoreLinq.Experimental.IAwaitQuery! +static MoreLinq.Experimental.ExperimentalEnumerable.AsSequential(this MoreLinq.Experimental.IAwaitQuery! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Experimental.ExperimentalEnumerable.AsUnordered(this MoreLinq.Experimental.IAwaitQuery! source) -> MoreLinq.Experimental.IAwaitQuery! +static MoreLinq.Experimental.ExperimentalEnumerable.Await(this System.Collections.Generic.IEnumerable! source, System.Func!>! evaluator) -> MoreLinq.Experimental.IAwaitQuery! +static MoreLinq.Experimental.ExperimentalEnumerable.Await(this System.Collections.Generic.IEnumerable!>! source) -> MoreLinq.Experimental.IAwaitQuery! +static MoreLinq.Experimental.ExperimentalEnumerable.AwaitCompletion(this System.Collections.Generic.IEnumerable! source, System.Func!>! evaluator, System.Func!, TResult>! resultSelector) -> MoreLinq.Experimental.IAwaitQuery! +static MoreLinq.Experimental.ExperimentalEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Buffers.ArrayPool! pool, System.Func!, System.Collections.Generic.IEnumerable!>! bucketProjectionSelector, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Experimental.ExperimentalEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Buffers.ArrayPool! pool, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Experimental.ExperimentalEnumerable.MaxConcurrency(this MoreLinq.Experimental.IAwaitQuery! source, int value) -> MoreLinq.Experimental.IAwaitQuery! +static MoreLinq.Experimental.ExperimentalEnumerable.Memoize(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Experimental.ExperimentalEnumerable.PreserveOrder(this MoreLinq.Experimental.IAwaitQuery! source, bool value) -> MoreLinq.Experimental.IAwaitQuery! +static MoreLinq.Experimental.ExperimentalEnumerable.Scheduler(this MoreLinq.Experimental.IAwaitQuery! source, System.Threading.Tasks.TaskScheduler! value) -> MoreLinq.Experimental.IAwaitQuery! +static MoreLinq.Experimental.ExperimentalEnumerable.TrySingle(this System.Collections.Generic.IEnumerable! source, TCardinality zero, TCardinality one, TCardinality many, System.Func! resultSelector) -> TResult +static MoreLinq.Experimental.ExperimentalEnumerable.TrySingle(this System.Collections.Generic.IEnumerable! source, TCardinality zero, TCardinality one, TCardinality many) -> (TCardinality Cardinality, T? Value) +static MoreLinq.Experimental.ExperimentalEnumerable.UnboundedConcurrency(this MoreLinq.Experimental.IAwaitQuery! source) -> MoreLinq.Experimental.IAwaitQuery! +static MoreLinq.Extensions.AcquireExtension.Acquire(this System.Collections.Generic.IEnumerable! source) -> TSource[]! +static MoreLinq.Extensions.AggregateExtension.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, TAccumulate4 seed4, System.Func! accumulator4, TAccumulate5 seed5, System.Func! accumulator5, TAccumulate6 seed6, System.Func! accumulator6, TAccumulate7 seed7, System.Func! accumulator7, TAccumulate8 seed8, System.Func! accumulator8, System.Func! resultSelector) -> TResult +static MoreLinq.Extensions.AggregateExtension.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, TAccumulate4 seed4, System.Func! accumulator4, TAccumulate5 seed5, System.Func! accumulator5, TAccumulate6 seed6, System.Func! accumulator6, TAccumulate7 seed7, System.Func! accumulator7, System.Func! resultSelector) -> TResult +static MoreLinq.Extensions.AggregateExtension.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, TAccumulate4 seed4, System.Func! accumulator4, TAccumulate5 seed5, System.Func! accumulator5, TAccumulate6 seed6, System.Func! accumulator6, System.Func! resultSelector) -> TResult +static MoreLinq.Extensions.AggregateExtension.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, TAccumulate4 seed4, System.Func! accumulator4, TAccumulate5 seed5, System.Func! accumulator5, System.Func! resultSelector) -> TResult +static MoreLinq.Extensions.AggregateExtension.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, TAccumulate4 seed4, System.Func! accumulator4, System.Func! resultSelector) -> TResult +static MoreLinq.Extensions.AggregateExtension.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, System.Func! resultSelector) -> TResult +static MoreLinq.Extensions.AggregateExtension.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, System.Func! resultSelector) -> TResult +static MoreLinq.Extensions.AggregateRightExtension.AggregateRight(this System.Collections.Generic.IEnumerable! source, TAccumulate seed, System.Func! func, System.Func! resultSelector) -> TResult +static MoreLinq.Extensions.AggregateRightExtension.AggregateRight(this System.Collections.Generic.IEnumerable! source, TAccumulate seed, System.Func! func) -> TAccumulate +static MoreLinq.Extensions.AggregateRightExtension.AggregateRight(this System.Collections.Generic.IEnumerable! source, System.Func! func) -> TSource +static MoreLinq.Extensions.AppendExtension.Append(this System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.AssertCountExtension.AssertCount(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.AssertCountExtension.AssertCount(this System.Collections.Generic.IEnumerable! source, int count, System.Func! errorSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.AssertExtension.Assert(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.AssertExtension.Assert(this System.Collections.Generic.IEnumerable! source, System.Func! predicate, System.Func? errorSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.AtLeastExtension.AtLeast(this System.Collections.Generic.IEnumerable! source, int count) -> bool +static MoreLinq.Extensions.AtMostExtension.AtMost(this System.Collections.Generic.IEnumerable! source, int count) -> bool +static MoreLinq.Extensions.BacksertExtension.Backsert(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, int index) -> 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.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ChooseExtension.Choose(this System.Collections.Generic.IEnumerable! source, System.Func! chooser) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.CompareCountExtension.CompareCount(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> int +static MoreLinq.Extensions.ConsumeExtension.Consume(this System.Collections.Generic.IEnumerable! source) -> void +static MoreLinq.Extensions.CountBetweenExtension.CountBetween(this System.Collections.Generic.IEnumerable! source, int min, int max) -> bool +static MoreLinq.Extensions.CountByExtension.CountBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.Extensions.CountByExtension.CountBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.Extensions.CountDownExtension.CountDown(this System.Collections.Generic.IEnumerable! source, int count, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DistinctByExtension.DistinctBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DistinctByExtension.DistinctBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.EndsWithExtension.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> bool +static MoreLinq.Extensions.EndsWithExtension.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEqualityComparer? comparer) -> bool +static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.EvaluateExtension.Evaluate(this System.Collections.Generic.IEnumerable!>! functions) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ExactlyExtension.Exactly(this System.Collections.Generic.IEnumerable! source, int count) -> bool +static MoreLinq.Extensions.ExceptByExtension.ExceptBy(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ExceptByExtension.ExceptBy(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? keyComparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ExcludeExtension.Exclude(this System.Collections.Generic.IEnumerable! sequence, int startIndex, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FallbackIfEmptyExtension.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, params T[]! fallback) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FallbackIfEmptyExtension.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEnumerable! fallback) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FallbackIfEmptyExtension.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, T fallback) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FallbackIfEmptyExtension.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, T fallback1, T fallback2) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FallbackIfEmptyExtension.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, T fallback1, T fallback2, T fallback3) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FallbackIfEmptyExtension.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, T fallback1, T fallback2, T fallback3, T fallback4) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FillBackwardExtension.FillBackward(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FillBackwardExtension.FillBackward(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FillBackwardExtension.FillBackward(this System.Collections.Generic.IEnumerable! source, System.Func! predicate, System.Func! fillSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FillForwardExtension.FillForward(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FillForwardExtension.FillForward(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FillForwardExtension.FillForward(this System.Collections.Generic.IEnumerable! source, System.Func! predicate, System.Func! fillSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FirstExtension.First(this MoreLinq.IExtremaEnumerable! source) -> T +static MoreLinq.Extensions.FirstOrDefaultExtension.FirstOrDefault(this MoreLinq.IExtremaEnumerable! source) -> T? +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.FoldExtension.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.Extensions.ForEachExtension.ForEach(this System.Collections.Generic.IEnumerable! source, System.Action! action) -> void +static MoreLinq.Extensions.ForEachExtension.ForEach(this System.Collections.Generic.IEnumerable! source, System.Action! action) -> void +static MoreLinq.Extensions.FullGroupJoinExtension.FullGroupJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func!, System.Collections.Generic.IEnumerable!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FullGroupJoinExtension.FullGroupJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func!, System.Collections.Generic.IEnumerable!, TResult>! resultSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FullGroupJoinExtension.FullGroupJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector) -> System.Collections.Generic.IEnumerable<(TKey Key, System.Collections.Generic.IEnumerable! First, System.Collections.Generic.IEnumerable! Second)>! +static MoreLinq.Extensions.FullGroupJoinExtension.FullGroupJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable<(TKey Key, System.Collections.Generic.IEnumerable! First, System.Collections.Generic.IEnumerable! Second)>! +static MoreLinq.Extensions.FullJoinExtension.FullJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FullJoinExtension.FullJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FullJoinExtension.FullJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.FullJoinExtension.FullJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.GroupAdjacentExtension.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func! elementSelector) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.GroupAdjacentExtension.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func! elementSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.GroupAdjacentExtension.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.GroupAdjacentExtension.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func!, TResult>! resultSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.GroupAdjacentExtension.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.GroupAdjacentExtension.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.IndexByExtension.IndexBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.Extensions.IndexByExtension.IndexBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.Extensions.IndexExtension.Index(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.Extensions.IndexExtension.Index(this System.Collections.Generic.IEnumerable! source, int startIndex) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.Extensions.InsertExtension.Insert(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, int index) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.InterleaveExtension.Interleave(this System.Collections.Generic.IEnumerable! sequence, params System.Collections.Generic.IEnumerable![]! otherSequences) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.LagExtension.Lag(this System.Collections.Generic.IEnumerable! source, int offset, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.LagExtension.Lag(this System.Collections.Generic.IEnumerable! source, int offset, TSource defaultLagValue, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.LastExtension.Last(this MoreLinq.IExtremaEnumerable! source) -> T +static MoreLinq.Extensions.LastOrDefaultExtension.LastOrDefault(this MoreLinq.IExtremaEnumerable! source) -> T? +static MoreLinq.Extensions.LeadExtension.Lead(this System.Collections.Generic.IEnumerable! source, int offset, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.LeadExtension.Lead(this System.Collections.Generic.IEnumerable! source, int offset, TSource defaultLeadValue, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.LeftJoinExtension.LeftJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.LeftJoinExtension.LeftJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.LeftJoinExtension.LeftJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.LeftJoinExtension.LeftJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.MaxByExtension.MaxBy(this System.Collections.Generic.IEnumerable! source, System.Func! selector) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.Extensions.MaxByExtension.MaxBy(this System.Collections.Generic.IEnumerable! source, System.Func! selector, System.Collections.Generic.IComparer? comparer) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.Extensions.MinByExtension.MinBy(this System.Collections.Generic.IEnumerable! source, System.Func! selector) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.Extensions.MinByExtension.MinBy(this System.Collections.Generic.IEnumerable! source, System.Func! selector, System.Collections.Generic.IComparer? comparer) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.Extensions.MaximaExtension.Maxima(this System.Collections.Generic.IEnumerable! source, System.Func! selector) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.Extensions.MaximaExtension.Maxima(this System.Collections.Generic.IEnumerable! source, System.Func! selector, System.Collections.Generic.IComparer? comparer) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.Extensions.MinimaExtension.Minima(this System.Collections.Generic.IEnumerable! source, System.Func! selector) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.Extensions.MinimaExtension.Minima(this System.Collections.Generic.IEnumerable! source, System.Func! selector, System.Collections.Generic.IComparer? comparer) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.Extensions.MoveExtension.Move(this System.Collections.Generic.IEnumerable! source, int fromIndex, int count, int toIndex) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.OrderByExtension.OrderBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, MoreLinq.OrderByDirection direction) -> System.Linq.IOrderedEnumerable! +static MoreLinq.Extensions.OrderByExtension.OrderBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IComparer? comparer, MoreLinq.OrderByDirection direction) -> System.Linq.IOrderedEnumerable! +static MoreLinq.Extensions.OrderedMergeExtension.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.OrderedMergeExtension.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.OrderedMergeExtension.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.OrderedMergeExtension.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.OrderedMergeExtension.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.OrderedMergeExtension.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.OrderedMergeExtension.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PadExtension.Pad(this System.Collections.Generic.IEnumerable! source, int width) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PadExtension.Pad(this System.Collections.Generic.IEnumerable! source, int width, System.Func! paddingSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PadExtension.Pad(this System.Collections.Generic.IEnumerable! source, int width, TSource padding) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PadStartExtension.PadStart(this System.Collections.Generic.IEnumerable! source, int width) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PadStartExtension.PadStart(this System.Collections.Generic.IEnumerable! source, int width, System.Func! paddingSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PadStartExtension.PadStart(this System.Collections.Generic.IEnumerable! source, int width, TSource padding) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PairwiseExtension.Pairwise(this System.Collections.Generic.IEnumerable! source, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PartialSortByExtension.PartialSortBy(this System.Collections.Generic.IEnumerable! source, int count, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PartialSortByExtension.PartialSortBy(this System.Collections.Generic.IEnumerable! source, int count, System.Func! keySelector, MoreLinq.OrderByDirection direction) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PartialSortByExtension.PartialSortBy(this System.Collections.Generic.IEnumerable! source, int count, System.Func! keySelector, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PartialSortByExtension.PartialSortBy(this System.Collections.Generic.IEnumerable! source, int count, System.Func! keySelector, System.Collections.Generic.IComparer? comparer, MoreLinq.OrderByDirection direction) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PartialSortExtension.PartialSort(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PartialSortExtension.PartialSort(this System.Collections.Generic.IEnumerable! source, int count, MoreLinq.OrderByDirection direction) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PartialSortExtension.PartialSort(this System.Collections.Generic.IEnumerable! source, int count, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PartialSortExtension.PartialSort(this System.Collections.Generic.IEnumerable! source, int count, System.Collections.Generic.IComparer? comparer, MoreLinq.OrderByDirection direction) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PartitionExtension.Partition(this System.Collections.Generic.IEnumerable!>! source, System.Func!, System.Collections.Generic.IEnumerable!, TResult>! resultSelector) -> TResult +static MoreLinq.Extensions.PartitionExtension.Partition(this System.Collections.Generic.IEnumerable!>! source, System.Func!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!, TResult>! resultSelector) -> TResult +static MoreLinq.Extensions.PartitionExtension.Partition(this System.Collections.Generic.IEnumerable! source, System.Func! predicate, System.Func!, System.Collections.Generic.IEnumerable!, TResult>! resultSelector) -> TResult +static MoreLinq.Extensions.PartitionExtension.Partition(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> (System.Collections.Generic.IEnumerable! True, System.Collections.Generic.IEnumerable! False) +static MoreLinq.Extensions.PartitionExtension.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key, System.Collections.Generic.IEqualityComparer? comparer, System.Func!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.Extensions.PartitionExtension.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key, System.Func!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.Extensions.PartitionExtension.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key1, TKey key2, System.Collections.Generic.IEqualityComparer? comparer, System.Func!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.Extensions.PartitionExtension.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key1, TKey key2, System.Func!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.Extensions.PartitionExtension.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key1, TKey key2, TKey key3, System.Collections.Generic.IEqualityComparer? comparer, System.Func!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.Extensions.PartitionExtension.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key1, TKey key2, TKey key3, System.Func!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.Extensions.PermutationsExtension.Permutations(this System.Collections.Generic.IEnumerable! sequence) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.PipeExtension.Pipe(this System.Collections.Generic.IEnumerable! source, System.Action! action) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PrependExtension.Prepend(this System.Collections.Generic.IEnumerable! source, TSource value) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.PreScanExtension.PreScan(this System.Collections.Generic.IEnumerable! source, System.Func! transformation, TSource identity) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RandomSubsetExtension.RandomSubset(this System.Collections.Generic.IEnumerable! source, int subsetSize) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RandomSubsetExtension.RandomSubset(this System.Collections.Generic.IEnumerable! source, int subsetSize, System.Random! rand) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RankByExtension.RankBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RankByExtension.RankBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RankExtension.Rank(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RankExtension.Rank(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RepeatExtension.Repeat(this System.Collections.Generic.IEnumerable! sequence) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RepeatExtension.Repeat(this System.Collections.Generic.IEnumerable! sequence, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RightJoinExtension.RightJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RightJoinExtension.RightJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RightJoinExtension.RightJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RightJoinExtension.RightJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.RunLengthEncodeExtension.RunLengthEncode(this System.Collections.Generic.IEnumerable! sequence) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.Extensions.RunLengthEncodeExtension.RunLengthEncode(this System.Collections.Generic.IEnumerable! sequence, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.Extensions.ScanByExtension.ScanBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func! seedSelector, System.Func! accumulator) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.Extensions.ScanByExtension.ScanBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func! seedSelector, System.Func! accumulator, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.Extensions.ScanExtension.Scan(this System.Collections.Generic.IEnumerable! source, TState seed, System.Func! transformation) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ScanExtension.Scan(this System.Collections.Generic.IEnumerable! source, System.Func! transformation) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ScanRightExtension.ScanRight(this System.Collections.Generic.IEnumerable! source, TAccumulate seed, System.Func! func) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ScanRightExtension.ScanRight(this System.Collections.Generic.IEnumerable! source, System.Func! func) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SegmentExtension.Segment(this System.Collections.Generic.IEnumerable! source, System.Func! newSegmentPredicate) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.SegmentExtension.Segment(this System.Collections.Generic.IEnumerable! source, System.Func! newSegmentPredicate) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.SegmentExtension.Segment(this System.Collections.Generic.IEnumerable! source, System.Func! newSegmentPredicate) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.ShuffleExtension.Shuffle(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ShuffleExtension.Shuffle(this System.Collections.Generic.IEnumerable! source, System.Random! rand) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SingleExtension.Single(this MoreLinq.IExtremaEnumerable! source) -> T +static MoreLinq.Extensions.SingleOrDefaultExtension.SingleOrDefault(this MoreLinq.IExtremaEnumerable! source) -> T? +static MoreLinq.Extensions.SkipLastExtension.SkipLast(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SkipUntilExtension.SkipUntil(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SliceExtension.Slice(this System.Collections.Generic.IEnumerable! sequence, int startIndex, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SortedMergeExtension.SortedMerge(this System.Collections.Generic.IEnumerable! source, MoreLinq.OrderByDirection direction, params System.Collections.Generic.IEnumerable![]! otherSequences) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SortedMergeExtension.SortedMerge(this System.Collections.Generic.IEnumerable! source, MoreLinq.OrderByDirection direction, System.Collections.Generic.IComparer? comparer, params System.Collections.Generic.IEnumerable![]! otherSequences) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, System.Func! separatorFunc, int count, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, System.Func! separatorFunc, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, int count, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, System.Collections.Generic.IEqualityComparer! comparer, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, System.Collections.Generic.IEqualityComparer? comparer, int count, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, System.Func! separatorFunc) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, System.Func! separatorFunc, int count) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, TSource separator) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, int count) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.SplitExtension.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, System.Collections.Generic.IEqualityComparer? comparer, int count) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.StartsWithExtension.StartsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> bool +static MoreLinq.Extensions.StartsWithExtension.StartsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEqualityComparer? comparer) -> bool +static MoreLinq.Extensions.SubsetsExtension.Subsets(this System.Collections.Generic.IEnumerable! sequence) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.SubsetsExtension.Subsets(this System.Collections.Generic.IEnumerable! sequence, int subsetSize) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.TagFirstLastExtension.TagFirstLast(this System.Collections.Generic.IEnumerable! source, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.TakeEveryExtension.TakeEvery(this System.Collections.Generic.IEnumerable! source, int step) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.TakeLastExtension.TakeLast(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.TakeUntilExtension.TakeUntil(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ThenByExtension.ThenBy(this System.Linq.IOrderedEnumerable! source, System.Func! keySelector, MoreLinq.OrderByDirection direction) -> System.Linq.IOrderedEnumerable! +static MoreLinq.Extensions.ThenByExtension.ThenBy(this System.Linq.IOrderedEnumerable! source, System.Func! keySelector, System.Collections.Generic.IComparer? comparer, MoreLinq.OrderByDirection direction) -> System.Linq.IOrderedEnumerable! +static MoreLinq.Extensions.ToArrayByIndexExtension.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, int length, System.Func! indexSelector, System.Func! resultSelector) -> TResult[]! +static MoreLinq.Extensions.ToArrayByIndexExtension.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, int length, System.Func! indexSelector, System.Func! resultSelector) -> TResult[]! +static MoreLinq.Extensions.ToArrayByIndexExtension.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, System.Func! indexSelector, System.Func! resultSelector) -> TResult[]! +static MoreLinq.Extensions.ToArrayByIndexExtension.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, System.Func! indexSelector, System.Func! resultSelector) -> TResult[]! +static MoreLinq.Extensions.ToArrayByIndexExtension.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, int length, System.Func! indexSelector) -> T[]! +static MoreLinq.Extensions.ToArrayByIndexExtension.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, System.Func! indexSelector) -> T[]! +static MoreLinq.Extensions.ToDataTableExtension.ToDataTable(this System.Collections.Generic.IEnumerable! source, TTable! table) -> TTable! +static MoreLinq.Extensions.ToDataTableExtension.ToDataTable(this System.Collections.Generic.IEnumerable! source, TTable! table, params System.Linq.Expressions.Expression!>![]! expressions) -> TTable! +static MoreLinq.Extensions.ToDataTableExtension.ToDataTable(this System.Collections.Generic.IEnumerable! source) -> System.Data.DataTable! +static MoreLinq.Extensions.ToDataTableExtension.ToDataTable(this System.Collections.Generic.IEnumerable! source, params System.Linq.Expressions.Expression!>![]! expressions) -> System.Data.DataTable! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDelimitedStringExtension.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.Extensions.ToDictionaryExtension.ToDictionary(this System.Collections.Generic.IEnumerable<(TKey Key, TValue Value)>! source) -> System.Collections.Generic.Dictionary! +static MoreLinq.Extensions.ToDictionaryExtension.ToDictionary(this System.Collections.Generic.IEnumerable<(TKey Key, TValue Value)>! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.Dictionary! +static MoreLinq.Extensions.ToDictionaryExtension.ToDictionary(this System.Collections.Generic.IEnumerable>! source) -> System.Collections.Generic.Dictionary! +static MoreLinq.Extensions.ToDictionaryExtension.ToDictionary(this System.Collections.Generic.IEnumerable>! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.Dictionary! +static MoreLinq.Extensions.ToHashSetExtension.ToHashSet(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.HashSet! +static MoreLinq.Extensions.ToHashSetExtension.ToHashSet(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.HashSet! +static MoreLinq.Extensions.ToLookupExtension.ToLookup(this System.Collections.Generic.IEnumerable<(TKey Key, TValue Value)>! source) -> System.Linq.ILookup! +static MoreLinq.Extensions.ToLookupExtension.ToLookup(this System.Collections.Generic.IEnumerable<(TKey Key, TValue Value)>! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Linq.ILookup! +static MoreLinq.Extensions.ToLookupExtension.ToLookup(this System.Collections.Generic.IEnumerable>! source) -> System.Linq.ILookup! +static MoreLinq.Extensions.ToLookupExtension.ToLookup(this System.Collections.Generic.IEnumerable>! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Linq.ILookup! +static MoreLinq.Extensions.TraceExtension.Trace(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.TraceExtension.Trace(this System.Collections.Generic.IEnumerable! source, string? format) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.TraceExtension.Trace(this System.Collections.Generic.IEnumerable! source, System.Func! formatter) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.TransposeExtension.Transpose(this System.Collections.Generic.IEnumerable!>! source) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.WindowExtension.Window(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.WindowLeftExtension.WindowLeft(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.WindowRightExtension.WindowRight(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.Extensions.ZipLongestExtension.ZipLongest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ZipLongestExtension.ZipLongest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ZipLongestExtension.ZipLongest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ZipShortestExtension.ZipShortest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ZipShortestExtension.ZipShortest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.ZipShortestExtension.ZipShortest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Acquire(this System.Collections.Generic.IEnumerable! source) -> TSource[]! +static MoreLinq.MoreEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, TAccumulate4 seed4, System.Func! accumulator4, TAccumulate5 seed5, System.Func! accumulator5, TAccumulate6 seed6, System.Func! accumulator6, TAccumulate7 seed7, System.Func! accumulator7, TAccumulate8 seed8, System.Func! accumulator8, System.Func! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, TAccumulate4 seed4, System.Func! accumulator4, TAccumulate5 seed5, System.Func! accumulator5, TAccumulate6 seed6, System.Func! accumulator6, TAccumulate7 seed7, System.Func! accumulator7, System.Func! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, TAccumulate4 seed4, System.Func! accumulator4, TAccumulate5 seed5, System.Func! accumulator5, TAccumulate6 seed6, System.Func! accumulator6, System.Func! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, TAccumulate4 seed4, System.Func! accumulator4, TAccumulate5 seed5, System.Func! accumulator5, System.Func! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, TAccumulate4 seed4, System.Func! accumulator4, System.Func! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, TAccumulate3 seed3, System.Func! accumulator3, System.Func! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Aggregate(this System.Collections.Generic.IEnumerable! source, TAccumulate1 seed1, System.Func! accumulator1, TAccumulate2 seed2, System.Func! accumulator2, System.Func! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.AggregateRight(this System.Collections.Generic.IEnumerable! source, TAccumulate seed, System.Func! func, System.Func! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.AggregateRight(this System.Collections.Generic.IEnumerable! source, TAccumulate seed, System.Func! func) -> TAccumulate +static MoreLinq.MoreEnumerable.AggregateRight(this System.Collections.Generic.IEnumerable! source, System.Func! func) -> TSource +static MoreLinq.MoreEnumerable.Append(System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Assert(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Assert(this System.Collections.Generic.IEnumerable! source, System.Func! predicate, System.Func? errorSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.AssertCount(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.AssertCount(this System.Collections.Generic.IEnumerable! source, int count, System.Func! errorSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.AtLeast(this System.Collections.Generic.IEnumerable! source, int count) -> bool +static MoreLinq.MoreEnumerable.AtMost(this System.Collections.Generic.IEnumerable! source, int count) -> bool +static MoreLinq.MoreEnumerable.Backsert(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, int index) -> 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.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Choose(this System.Collections.Generic.IEnumerable! source, System.Func! chooser) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.CompareCount(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> int +static MoreLinq.MoreEnumerable.Consume(this System.Collections.Generic.IEnumerable! source) -> void +static MoreLinq.MoreEnumerable.CountBetween(this System.Collections.Generic.IEnumerable! source, int min, int max) -> bool +static MoreLinq.MoreEnumerable.CountBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.MoreEnumerable.CountBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.MoreEnumerable.CountDown(this System.Collections.Generic.IEnumerable! source, int count, System.Func! resultSelector) -> 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.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> bool +static MoreLinq.MoreEnumerable.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEqualityComparer? comparer) -> bool +static MoreLinq.MoreEnumerable.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Evaluate(this System.Collections.Generic.IEnumerable!>! functions) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Exactly(this System.Collections.Generic.IEnumerable! source, int count) -> bool +static MoreLinq.MoreEnumerable.ExceptBy(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.ExceptBy(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? keyComparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Exclude(this System.Collections.Generic.IEnumerable! sequence, int startIndex, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, params T[]! fallback) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEnumerable! fallback) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, T fallback) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, T fallback1, T fallback2) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, T fallback1, T fallback2, T fallback3) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FallbackIfEmpty(this System.Collections.Generic.IEnumerable! source, T fallback1, T fallback2, T fallback3, T fallback4) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FillBackward(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FillBackward(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FillBackward(this System.Collections.Generic.IEnumerable! source, System.Func! predicate, System.Func! fillSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FillForward(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FillForward(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FillForward(this System.Collections.Generic.IEnumerable! source, System.Func! predicate, System.Func! fillSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.First(this MoreLinq.IExtremaEnumerable! source) -> T +static MoreLinq.MoreEnumerable.FirstOrDefault(this MoreLinq.IExtremaEnumerable! source) -> T? +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.Fold(this System.Collections.Generic.IEnumerable! source, System.Func! folder) -> TResult +static MoreLinq.MoreEnumerable.ForEach(this System.Collections.Generic.IEnumerable! source, System.Action! action) -> void +static MoreLinq.MoreEnumerable.ForEach(this System.Collections.Generic.IEnumerable! source, System.Action! action) -> void +static MoreLinq.MoreEnumerable.From(params System.Func![]! functions) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.From(System.Func! function) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.From(System.Func! function1, System.Func! function2) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.From(System.Func! function1, System.Func! function2, System.Func! function3) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FullGroupJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func!, System.Collections.Generic.IEnumerable!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FullGroupJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func!, System.Collections.Generic.IEnumerable!, TResult>! resultSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FullGroupJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector) -> System.Collections.Generic.IEnumerable<(TKey Key, System.Collections.Generic.IEnumerable! First, System.Collections.Generic.IEnumerable! Second)>! +static MoreLinq.MoreEnumerable.FullGroupJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable<(TKey Key, System.Collections.Generic.IEnumerable! First, System.Collections.Generic.IEnumerable! Second)>! +static MoreLinq.MoreEnumerable.FullJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FullJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FullJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.FullJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Generate(TResult initial, System.Func! generator) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.GenerateByIndex(System.Func! generator) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func! elementSelector) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func! elementSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func!, TResult>! resultSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.GroupAdjacent(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Index(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.MoreEnumerable.Index(this System.Collections.Generic.IEnumerable! source, int startIndex) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.MoreEnumerable.IndexBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.MoreEnumerable.IndexBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.MoreEnumerable.Insert(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, int index) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Interleave(this System.Collections.Generic.IEnumerable! sequence, params System.Collections.Generic.IEnumerable![]! otherSequences) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Lag(this System.Collections.Generic.IEnumerable! source, int offset, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Lag(this System.Collections.Generic.IEnumerable! source, int offset, TSource defaultLagValue, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Last(this MoreLinq.IExtremaEnumerable! source) -> T +static MoreLinq.MoreEnumerable.LastOrDefault(this MoreLinq.IExtremaEnumerable! source) -> T? +static MoreLinq.MoreEnumerable.Lead(this System.Collections.Generic.IEnumerable! source, int offset, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Lead(this System.Collections.Generic.IEnumerable! source, int offset, TSource defaultLeadValue, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.LeftJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.LeftJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.LeftJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.LeftJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.MaxBy(System.Collections.Generic.IEnumerable! source, System.Func! selector) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.MoreEnumerable.MaxBy(System.Collections.Generic.IEnumerable! source, System.Func! selector, System.Collections.Generic.IComparer? comparer) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.MoreEnumerable.MinBy(System.Collections.Generic.IEnumerable! source, System.Func! selector) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.MoreEnumerable.MinBy(System.Collections.Generic.IEnumerable! source, System.Func! selector, System.Collections.Generic.IComparer? comparer) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.MoreEnumerable.Maxima(this System.Collections.Generic.IEnumerable! source, System.Func! selector) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.MoreEnumerable.Maxima(this System.Collections.Generic.IEnumerable! source, System.Func! selector, System.Collections.Generic.IComparer? comparer) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.MoreEnumerable.Minima(this System.Collections.Generic.IEnumerable! source, System.Func! selector) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.MoreEnumerable.Minima(this System.Collections.Generic.IEnumerable! source, System.Func! selector, System.Collections.Generic.IComparer? comparer) -> MoreLinq.IExtremaEnumerable! +static MoreLinq.MoreEnumerable.Move(this System.Collections.Generic.IEnumerable! source, int fromIndex, int count, int toIndex) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.OrderBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, MoreLinq.OrderByDirection direction) -> System.Linq.IOrderedEnumerable! +static MoreLinq.MoreEnumerable.OrderBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IComparer? comparer, MoreLinq.OrderByDirection direction) -> System.Linq.IOrderedEnumerable! +static MoreLinq.MoreEnumerable.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.OrderedMerge(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! firstSelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Pad(this System.Collections.Generic.IEnumerable! source, int width) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Pad(this System.Collections.Generic.IEnumerable! source, int width, System.Func! paddingSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Pad(this System.Collections.Generic.IEnumerable! source, int width, TSource padding) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PadStart(this System.Collections.Generic.IEnumerable! source, int width) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PadStart(this System.Collections.Generic.IEnumerable! source, int width, System.Func! paddingSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PadStart(this System.Collections.Generic.IEnumerable! source, int width, TSource padding) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Pairwise(this System.Collections.Generic.IEnumerable! source, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PartialSort(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PartialSort(this System.Collections.Generic.IEnumerable! source, int count, MoreLinq.OrderByDirection direction) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PartialSort(this System.Collections.Generic.IEnumerable! source, int count, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PartialSort(this System.Collections.Generic.IEnumerable! source, int count, System.Collections.Generic.IComparer? comparer, MoreLinq.OrderByDirection direction) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PartialSortBy(this System.Collections.Generic.IEnumerable! source, int count, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PartialSortBy(this System.Collections.Generic.IEnumerable! source, int count, System.Func! keySelector, MoreLinq.OrderByDirection direction) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PartialSortBy(this System.Collections.Generic.IEnumerable! source, int count, System.Func! keySelector, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PartialSortBy(this System.Collections.Generic.IEnumerable! source, int count, System.Func! keySelector, System.Collections.Generic.IComparer? comparer, MoreLinq.OrderByDirection direction) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Partition(this System.Collections.Generic.IEnumerable!>! source, System.Func!, System.Collections.Generic.IEnumerable!, TResult>! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Partition(this System.Collections.Generic.IEnumerable!>! source, System.Func!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!, TResult>! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Partition(this System.Collections.Generic.IEnumerable! source, System.Func! predicate, System.Func!, System.Collections.Generic.IEnumerable!, TResult>! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Partition(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> (System.Collections.Generic.IEnumerable! True, System.Collections.Generic.IEnumerable! False) +static MoreLinq.MoreEnumerable.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key, System.Collections.Generic.IEqualityComparer? comparer, System.Func!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key, System.Func!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key1, TKey key2, System.Collections.Generic.IEqualityComparer? comparer, System.Func!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key1, TKey key2, System.Func!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key1, TKey key2, TKey key3, System.Collections.Generic.IEqualityComparer? comparer, System.Func!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Partition(this System.Collections.Generic.IEnumerable!>! source, TKey key1, TKey key2, TKey key3, System.Func!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!, System.Collections.Generic.IEnumerable!>!, TResult>! resultSelector) -> TResult +static MoreLinq.MoreEnumerable.Permutations(this System.Collections.Generic.IEnumerable! sequence) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Pipe(this System.Collections.Generic.IEnumerable! source, System.Action! action) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Prepend(System.Collections.Generic.IEnumerable! source, TSource value) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.PreScan(this System.Collections.Generic.IEnumerable! source, System.Func! transformation, TSource identity) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Random() -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Random(int maxValue) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Random(int minValue, int maxValue) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Random(System.Random! rand) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Random(System.Random! rand, int maxValue) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Random(System.Random! rand, int minValue, int maxValue) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RandomDouble() -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RandomDouble(System.Random! rand) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RandomSubset(this System.Collections.Generic.IEnumerable! source, int subsetSize) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RandomSubset(this System.Collections.Generic.IEnumerable! source, int subsetSize, System.Random! rand) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Rank(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Rank(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RankBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RankBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Repeat(this System.Collections.Generic.IEnumerable! sequence) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Repeat(this System.Collections.Generic.IEnumerable! sequence, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Return(T item) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RightJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RightJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! firstKeySelector, System.Func! secondKeySelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RightJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! secondSelector, System.Func! bothSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RightJoin(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! keySelector, System.Func! secondSelector, System.Func! bothSelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.RunLengthEncode(this System.Collections.Generic.IEnumerable! sequence) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.MoreEnumerable.RunLengthEncode(this System.Collections.Generic.IEnumerable! sequence, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.MoreEnumerable.Scan(this System.Collections.Generic.IEnumerable! source, TState seed, System.Func! transformation) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Scan(this System.Collections.Generic.IEnumerable! source, System.Func! transformation) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.ScanBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func! seedSelector, System.Func! accumulator) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.MoreEnumerable.ScanBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Func! seedSelector, System.Func! accumulator, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable>! +static MoreLinq.MoreEnumerable.ScanRight(this System.Collections.Generic.IEnumerable! source, TAccumulate seed, System.Func! func) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.ScanRight(this System.Collections.Generic.IEnumerable! source, System.Func! func) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Segment(this System.Collections.Generic.IEnumerable! source, System.Func! newSegmentPredicate) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Segment(this System.Collections.Generic.IEnumerable! source, System.Func! newSegmentPredicate) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Segment(this System.Collections.Generic.IEnumerable! source, System.Func! newSegmentPredicate) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Sequence(int start, int stop) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Sequence(int start, int stop, int step) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Shuffle(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Shuffle(this System.Collections.Generic.IEnumerable! source, System.Random! rand) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Single(this MoreLinq.IExtremaEnumerable! source) -> T +static MoreLinq.MoreEnumerable.SingleOrDefault(this MoreLinq.IExtremaEnumerable! source) -> T? +static MoreLinq.MoreEnumerable.SkipLast(System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.SkipUntil(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Slice(this System.Collections.Generic.IEnumerable! sequence, int startIndex, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.SortedMerge(this System.Collections.Generic.IEnumerable! source, MoreLinq.OrderByDirection direction, params System.Collections.Generic.IEnumerable![]! otherSequences) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.SortedMerge(this System.Collections.Generic.IEnumerable! source, MoreLinq.OrderByDirection direction, System.Collections.Generic.IComparer? comparer, params System.Collections.Generic.IEnumerable![]! otherSequences) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, System.Func! separatorFunc, int count, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, System.Func! separatorFunc, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, int count, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, System.Collections.Generic.IEqualityComparer! comparer, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, System.Collections.Generic.IEqualityComparer? comparer, int count, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, System.Func!, TResult>! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, System.Func! separatorFunc) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, System.Func! separatorFunc, int count) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, TSource separator) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, int count) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Split(this System.Collections.Generic.IEnumerable! source, TSource separator, System.Collections.Generic.IEqualityComparer? comparer, int count) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.StartsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> bool +static MoreLinq.MoreEnumerable.StartsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEqualityComparer? comparer) -> bool +static MoreLinq.MoreEnumerable.Subsets(this System.Collections.Generic.IEnumerable! sequence) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.Subsets(this System.Collections.Generic.IEnumerable! sequence, int subsetSize) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.TagFirstLast(this System.Collections.Generic.IEnumerable! source, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.TakeEvery(this System.Collections.Generic.IEnumerable! source, int step) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.TakeLast(System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.TakeUntil(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.ThenBy(this System.Linq.IOrderedEnumerable! source, System.Func! keySelector, MoreLinq.OrderByDirection direction) -> System.Linq.IOrderedEnumerable! +static MoreLinq.MoreEnumerable.ThenBy(this System.Linq.IOrderedEnumerable! source, System.Func! keySelector, System.Collections.Generic.IComparer? comparer, MoreLinq.OrderByDirection direction) -> System.Linq.IOrderedEnumerable! +static MoreLinq.MoreEnumerable.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, int length, System.Func! indexSelector, System.Func! resultSelector) -> TResult[]! +static MoreLinq.MoreEnumerable.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, int length, System.Func! indexSelector, System.Func! resultSelector) -> TResult[]! +static MoreLinq.MoreEnumerable.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, System.Func! indexSelector, System.Func! resultSelector) -> TResult[]! +static MoreLinq.MoreEnumerable.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, System.Func! indexSelector, System.Func! resultSelector) -> TResult[]! +static MoreLinq.MoreEnumerable.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, int length, System.Func! indexSelector) -> T[]! +static MoreLinq.MoreEnumerable.ToArrayByIndex(this System.Collections.Generic.IEnumerable! source, System.Func! indexSelector) -> T[]! +static MoreLinq.MoreEnumerable.ToDataTable(this System.Collections.Generic.IEnumerable! source, TTable! table) -> TTable! +static MoreLinq.MoreEnumerable.ToDataTable(this System.Collections.Generic.IEnumerable! source, TTable! table, params System.Linq.Expressions.Expression!>![]! expressions) -> TTable! +static MoreLinq.MoreEnumerable.ToDataTable(this System.Collections.Generic.IEnumerable! source) -> System.Data.DataTable! +static MoreLinq.MoreEnumerable.ToDataTable(this System.Collections.Generic.IEnumerable! source, params System.Linq.Expressions.Expression!>![]! expressions) -> System.Data.DataTable! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDelimitedString(this System.Collections.Generic.IEnumerable! source, string! delimiter) -> string! +static MoreLinq.MoreEnumerable.ToDictionary(this System.Collections.Generic.IEnumerable<(TKey Key, TValue Value)>! source) -> System.Collections.Generic.Dictionary! +static MoreLinq.MoreEnumerable.ToDictionary(this System.Collections.Generic.IEnumerable<(TKey Key, TValue Value)>! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.Dictionary! +static MoreLinq.MoreEnumerable.ToDictionary(this System.Collections.Generic.IEnumerable>! source) -> System.Collections.Generic.Dictionary! +static MoreLinq.MoreEnumerable.ToDictionary(this System.Collections.Generic.IEnumerable>! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.Dictionary! +static MoreLinq.MoreEnumerable.ToHashSet(System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.HashSet! +static MoreLinq.MoreEnumerable.ToHashSet(System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.HashSet! +static MoreLinq.MoreEnumerable.ToLookup(this System.Collections.Generic.IEnumerable<(TKey Key, TValue Value)>! source) -> System.Linq.ILookup! +static MoreLinq.MoreEnumerable.ToLookup(this System.Collections.Generic.IEnumerable<(TKey Key, TValue Value)>! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Linq.ILookup! +static MoreLinq.MoreEnumerable.ToLookup(this System.Collections.Generic.IEnumerable>! source) -> System.Linq.ILookup! +static MoreLinq.MoreEnumerable.ToLookup(this System.Collections.Generic.IEnumerable>! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Linq.ILookup! +static MoreLinq.MoreEnumerable.Trace(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Trace(this System.Collections.Generic.IEnumerable! source, string? format) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Trace(this System.Collections.Generic.IEnumerable! source, System.Func! formatter) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Transpose(this System.Collections.Generic.IEnumerable!>! source) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.TraverseBreadthFirst(T root, System.Func!>! childrenSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.TraverseDepthFirst(T root, System.Func!>! childrenSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Unfold(TState state, System.Func! generator, System.Func! predicate, System.Func! stateSelector, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Window(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.WindowLeft(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.WindowRight(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! +static MoreLinq.MoreEnumerable.ZipLongest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.ZipLongest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.ZipLongest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.ZipShortest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.ZipShortest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.ZipShortest(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! +static readonly MoreLinq.Experimental.AwaitQueryOptions.Default -> MoreLinq.Experimental.AwaitQueryOptions! +~static MoreLinq.Extensions.FlattenExtension.Flatten(this System.Collections.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +~static MoreLinq.Extensions.FlattenExtension.Flatten(this System.Collections.IEnumerable! source, System.Func! selector) -> System.Collections.Generic.IEnumerable! +~static MoreLinq.Extensions.FlattenExtension.Flatten(this System.Collections.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +~static MoreLinq.MoreEnumerable.Flatten(this System.Collections.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +~static MoreLinq.MoreEnumerable.Flatten(this System.Collections.IEnumerable! source, System.Func! selector) -> System.Collections.Generic.IEnumerable! +~static MoreLinq.MoreEnumerable.Flatten(this System.Collections.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/RandomSubset.cs b/MoreLinq/RandomSubset.cs index d0716f57d..f5f0de015 100644 --- a/MoreLinq/RandomSubset.cs +++ b/MoreLinq/RandomSubset.cs @@ -76,8 +76,11 @@ static IEnumerable RandomSubsetImpl(IEnumerable source, Random rand, Fu if (array.Length < subsetSize) { +#pragma warning disable CA2208 // Instantiate argument exceptions correctly + // TODO Throw InvalidOperationException instead? throw new ArgumentOutOfRangeException(nameof(subsetSize), "Subset size must be less than or equal to the source length."); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly } var m = 0; // keeps track of count items shuffled diff --git a/MoreLinq/SequenceException.cs b/MoreLinq/SequenceException.cs index c2226587b..6c5088984 100644 --- a/MoreLinq/SequenceException.cs +++ b/MoreLinq/SequenceException.cs @@ -18,14 +18,13 @@ namespace MoreLinq { using System; - using System.Runtime.Serialization; /// /// The exception that is thrown for a sequence that fails a condition. /// [Serializable] - public class SequenceException : Exception + public partial class SequenceException : Exception { const string DefaultMessage = "Error in sequence."; @@ -55,7 +54,20 @@ public SequenceException(string? message) : public SequenceException(string? message, Exception? innerException) : base(string.IsNullOrEmpty(message) ? DefaultMessage : message, innerException) { } + } +} +#if !NET7_0_OR_GREATER + +// BinaryFormatter serialization APIs are obsolete +// https://learn.microsoft.com/en-us/dotnet/core/compatibility/serialization/7.0/binaryformatter-apis-produce-errors + +namespace MoreLinq +{ + using System.Runtime.Serialization; + + partial class SequenceException + { /// /// Initializes a new instance of the class /// with serialized data. @@ -67,3 +79,5 @@ protected SequenceException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } + +#endif // !NET8_0_OR_GREATER diff --git a/MoreLinq/UnreachableException.cs b/MoreLinq/UnreachableException.cs index 80e4cf0eb..137facb25 100644 --- a/MoreLinq/UnreachableException.cs +++ b/MoreLinq/UnreachableException.cs @@ -24,7 +24,11 @@ // SOFTWARE. #endregion -#if !NET7_0_OR_GREATER +#if NET7_0_OR_GREATER + +global using UnreachableException = System.Diagnostics.UnreachableException; + +#else namespace MoreLinq { @@ -55,4 +59,4 @@ public UnreachableException(string? message, Exception? innerException) : } } -#endif // !NET7_0_OR_GREATER +#endif // NET7_0_OR_GREATER diff --git a/appveyor.yml b/appveyor.yml index 27d35a0ad..98a25c24b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,8 +49,10 @@ install: - git reset --hard - ps: if ($isWindows) { tools\dotnet-install.ps1 -JSonFile global.json } - ps: if ($isWindows) { tools\dotnet-install.ps1 -Runtime dotnet -Version 6.0.11 -SkipNonVersionedFiles } +- ps: if ($isWindows) { tools\dotnet-install.ps1 -Runtime dotnet -Version 7.0.14 -SkipNonVersionedFiles } - sh: ./tools/dotnet-install.sh --jsonfile global.json - sh: ./tools/dotnet-install.sh --runtime dotnet --version 6.0.11 --skip-non-versioned-files +- sh: ./tools/dotnet-install.sh --runtime dotnet --version 7.0.14 --skip-non-versioned-files - sh: export PATH="$HOME/.dotnet:$PATH" before_build: - dotnet --info diff --git a/bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj b/bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj index e810d01e0..39132fd4d 100644 --- a/bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj +++ b/bld/ExtensionsGenerator/MoreLinq.ExtensionsGenerator.csproj @@ -1,12 +1,12 @@  Exe - net7.0 + net8.0 false - + diff --git a/global.json b/global.json index 5bf3e71b6..391ba3c2a 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.200", + "version": "8.0.100", "rollForward": "latestFeature" } } diff --git a/test.cmd b/test.cmd index 1cc6d54be..640f802b9 100644 --- a/test.cmd +++ b/test.cmd @@ -8,6 +8,8 @@ setlocal if not defined SKIP_TEST_BUILD set SKIP_TEST_BUILD=false if %SKIP_TEST_BUILD%==false call build || exit /b 1 call :clean ^ + && call :test net8.0 Debug ^ + && call :test net8.0 Release ^ && call :test net7.0 Debug ^ && call :test net7.0 Release ^ && call :test net6.0 Debug ^ diff --git a/test.sh b/test.sh index 2548482d1..fbe65fd50 100755 --- a/test.sh +++ b/test.sh @@ -12,7 +12,7 @@ if [[ -z "$1" ]]; then else configs="$1" fi -for f in net6.0 net7.0; do +for f in net6.0 net7.0 net8.0; do for c in $configs; do dotnet test --no-build -c $c -f $f --settings MoreLinq.Test/coverlet.runsettings MoreLinq.Test TEST_RESULTS_DIR="$(ls -dc MoreLinq.Test/TestResults/* | head -1)" From 3d26c34553e537d2f3b1ec1d9486d3ba0eacc934 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Fri, 17 Nov 2023 19:12:34 +0100 Subject: [PATCH 37/51] Update to using C# 12 --- Directory.Build.props | 2 +- MoreLinq.Test/AppendTest.cs | 2 +- MoreLinq.Test/AssertCountTest.cs | 12 +--- MoreLinq.Test/AssertTest.cs | 5 +- MoreLinq.Test/Async/WatchableEnumerator.cs | 8 +-- MoreLinq.Test/BatchTest.cs | 2 +- MoreLinq.Test/BreakingCollection.cs | 6 +- MoreLinq.Test/BreakingList.cs | 7 +- MoreLinq.Test/BreakingReadOnlyCollection.cs | 7 +- MoreLinq.Test/BreakingReadOnlyList.cs | 8 +-- MoreLinq.Test/CountDownTest.cs | 40 +++++------- MoreLinq.Test/DistinctByTest.cs | 6 +- MoreLinq.Test/ExceptByTest.cs | 16 ++--- MoreLinq.Test/FlattenTest.cs | 30 +++------ MoreLinq.Test/GroupAdjacentTest.cs | 2 +- MoreLinq.Test/PermutationsTest.cs | 72 ++++++++++----------- MoreLinq.Test/PrependTest.cs | 6 +- MoreLinq.Test/ReadOnlyCollection.cs | 7 +- MoreLinq.Test/SequenceReader.cs | 18 ++---- MoreLinq.Test/SubsetTest.cs | 52 +++++++-------- MoreLinq.Test/TestException.cs | 3 +- MoreLinq.Test/ToDataTableTest.cs | 19 ++---- MoreLinq.Test/TransposeTest.cs | 54 ++++++++-------- MoreLinq.Test/TraverseTest.cs | 12 +--- MoreLinq.Test/TrySingleTest.cs | 16 ++--- MoreLinq.Test/WatchableEnumerator.cs | 8 +-- MoreLinq/Acquire.cs | 2 +- MoreLinq/Collections/Dictionary.cs | 10 ++- MoreLinq/CountBy.cs | 4 +- MoreLinq/Delegating.cs | 29 +++------ MoreLinq/EmptyArray.cs | 14 ---- MoreLinq/EquiZip.cs | 4 +- MoreLinq/Experimental/Async/Merge.cs | 6 +- MoreLinq/Experimental/Await.cs | 18 ++---- MoreLinq/Experimental/Batch.cs | 4 +- MoreLinq/Experimental/Memoize.cs | 12 +--- MoreLinq/FillBackward.cs | 2 +- MoreLinq/GroupAdjacent.cs | 15 ++--- MoreLinq/Maxima.cs | 28 +++----- MoreLinq/Partition.cs | 2 +- MoreLinq/PendNode.cs | 5 +- MoreLinq/Reactive/Subject.cs | 2 +- MoreLinq/Return.cs | 6 +- MoreLinq/ReverseComparer.cs | 7 +- MoreLinq/Segment.cs | 2 +- MoreLinq/SequenceException.cs | 2 + MoreLinq/SortedMerge.cs | 7 +- MoreLinq/Split.cs | 2 +- MoreLinq/ToArrayByIndex.cs | 4 +- MoreLinq/ToDataTable.cs | 2 +- bld/ExtensionsGenerator/Program.cs | 29 ++++----- 51 files changed, 260 insertions(+), 378 deletions(-) delete mode 100644 MoreLinq/EmptyArray.cs diff --git a/Directory.Build.props b/Directory.Build.props index 9fc11a600..222a1c0a6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 11 + 12 enable true 8.0-all diff --git a/MoreLinq.Test/AppendTest.cs b/MoreLinq.Test/AppendTest.cs index 58dbd6c9d..0398a5658 100644 --- a/MoreLinq.Test/AppendTest.cs +++ b/MoreLinq.Test/AppendTest.cs @@ -37,7 +37,7 @@ public void AppendWithNonEmptyHeadSequence() [Test] public void AppendWithEmptyHeadSequence() { - string[] head = { }; + string[] head = []; var tail = "first"; var whole = head.Append(tail); whole.AssertSequenceEqual("first"); diff --git a/MoreLinq.Test/AssertCountTest.cs b/MoreLinq.Test/AssertCountTest.cs index b8dfe839d..05e5ae182 100644 --- a/MoreLinq.Test/AssertCountTest.cs +++ b/MoreLinq.Test/AssertCountTest.cs @@ -90,16 +90,10 @@ public void AssertCountShortSequenceWithErrorSelector() .And.Count.EqualTo(4)); } - sealed class TestException : Exception + sealed class TestException(int cmp, int count) : Exception { - public int Cmp { get; } - public int Count { get; } - - public TestException(int cmp, int count) - { - Cmp = cmp; - Count = count; - } + public int Cmp { get; } = cmp; + public int Count { get; } = count; } [Test] diff --git a/MoreLinq.Test/AssertTest.cs b/MoreLinq.Test/AssertTest.cs index ecd288ce6..ad037a030 100644 --- a/MoreLinq.Test/AssertTest.cs +++ b/MoreLinq.Test/AssertTest.cs @@ -63,10 +63,9 @@ public void AssertSequenceWithInvalidElementsAndCustomError() .With.Property(nameof(ValueException.Value)).EqualTo(7)); } - sealed class ValueException : Exception + sealed class ValueException(object value) : Exception { - public object Value { get; } - public ValueException(object value) => Value = value; + public object Value { get; } = value; } } } diff --git a/MoreLinq.Test/Async/WatchableEnumerator.cs b/MoreLinq.Test/Async/WatchableEnumerator.cs index 0920b36e2..e4635533f 100644 --- a/MoreLinq.Test/Async/WatchableEnumerator.cs +++ b/MoreLinq.Test/Async/WatchableEnumerator.cs @@ -26,16 +26,14 @@ partial class TestExtensions public static WatchableEnumerator AsWatchable(this IAsyncEnumerator source) => new(source); } - sealed class WatchableEnumerator : IAsyncEnumerator + sealed class WatchableEnumerator(IAsyncEnumerator source) : + IAsyncEnumerator { - readonly IAsyncEnumerator _source; + readonly IAsyncEnumerator _source = source ?? throw new ArgumentNullException(nameof(source)); public event EventHandler? Disposed; public event EventHandler? MoveNextCalled; - public WatchableEnumerator(IAsyncEnumerator source) => - _source = source ?? throw new ArgumentNullException(nameof(source)); - public T Current => _source.Current; public async ValueTask MoveNextAsync() diff --git a/MoreLinq.Test/BatchTest.cs b/MoreLinq.Test/BatchTest.cs index ee10acfb2..f755bc114 100644 --- a/MoreLinq.Test/BatchTest.cs +++ b/MoreLinq.Test/BatchTest.cs @@ -360,7 +360,7 @@ public void BatchBucketSelectorCurrentList() using var pool = new TestArrayPool(); int[]? bucketSelectorItems = null; - var result = input.Batch(4, pool, current => bucketSelectorItems = current.ToArray(), _ => 0); + var result = input.Batch(4, pool, current => bucketSelectorItems = [..current], _ => 0); using var reader = result.Read(); _ = reader.Read(); diff --git a/MoreLinq.Test/BreakingCollection.cs b/MoreLinq.Test/BreakingCollection.cs index 6cb4d03ed..8dda669cb 100644 --- a/MoreLinq.Test/BreakingCollection.cs +++ b/MoreLinq.Test/BreakingCollection.cs @@ -20,12 +20,12 @@ namespace MoreLinq.Test using System; using System.Collections.Generic; - class BreakingCollection : BreakingSequence, ICollection + class BreakingCollection(IList list) : + BreakingSequence, ICollection { - protected readonly IList List; + protected readonly IList List = list; public BreakingCollection(params T[] values) : this((IList)values) { } - public BreakingCollection(IList list) => List = list; public int Count => List.Count; diff --git a/MoreLinq.Test/BreakingList.cs b/MoreLinq.Test/BreakingList.cs index 5f054aba2..32673c6aa 100644 --- a/MoreLinq.Test/BreakingList.cs +++ b/MoreLinq.Test/BreakingList.cs @@ -28,10 +28,11 @@ namespace MoreLinq.Test /// expected to be lazily evaluated. /// - sealed class BreakingList : BreakingCollection, IList + sealed class BreakingList(List list) : + BreakingCollection(list), + IList { - public BreakingList() : this(new List()) { } - public BreakingList(List list) : base(list) { } + public BreakingList() : this([]) { } public int IndexOf(T item) => List.IndexOf(item); public void Insert(int index, T item) => throw new NotImplementedException(); diff --git a/MoreLinq.Test/BreakingReadOnlyCollection.cs b/MoreLinq.Test/BreakingReadOnlyCollection.cs index 9748e77ba..927a9f608 100644 --- a/MoreLinq.Test/BreakingReadOnlyCollection.cs +++ b/MoreLinq.Test/BreakingReadOnlyCollection.cs @@ -19,12 +19,13 @@ namespace MoreLinq.Test { using System.Collections.Generic; - class BreakingReadOnlyCollection : BreakingSequence, IReadOnlyCollection + class BreakingReadOnlyCollection(IReadOnlyCollection collection) : + BreakingSequence, IReadOnlyCollection { - readonly IReadOnlyCollection _collection; + readonly IReadOnlyCollection _collection = collection; public BreakingReadOnlyCollection(params T[] values) : this((IReadOnlyCollection)values) { } - public BreakingReadOnlyCollection(IReadOnlyCollection collection) => _collection = collection; + public int Count => _collection.Count; } } diff --git a/MoreLinq.Test/BreakingReadOnlyList.cs b/MoreLinq.Test/BreakingReadOnlyList.cs index 0e368c8aa..45c84963c 100644 --- a/MoreLinq.Test/BreakingReadOnlyList.cs +++ b/MoreLinq.Test/BreakingReadOnlyList.cs @@ -27,13 +27,13 @@ namespace MoreLinq.Test /// expected to be lazily evaluated. /// - sealed class BreakingReadOnlyList : BreakingReadOnlyCollection, IReadOnlyList + sealed class BreakingReadOnlyList(IReadOnlyList list) : + BreakingReadOnlyCollection(list), + IReadOnlyList { - readonly IReadOnlyList _list; + readonly IReadOnlyList _list = list; public BreakingReadOnlyList(params T[] values) : this((IReadOnlyList)values) { } - public BreakingReadOnlyList(IReadOnlyList list) : base(list) - => _list = list; public T this[int index] => _list[index]; } diff --git a/MoreLinq.Test/CountDownTest.cs b/MoreLinq.Test/CountDownTest.cs index b7c635667..1be4c6846 100644 --- a/MoreLinq.Test/CountDownTest.cs +++ b/MoreLinq.Test/CountDownTest.cs @@ -44,15 +44,15 @@ public void WithNegativeCount() static IEnumerable GetData(Func selector) { var xs = Enumerable.Range(0, 5).ToArray(); - yield return selector(xs, -1, new int?[] { null, null, null, null, null }); - yield return selector(xs, 0, new int?[] { null, null, null, null, null }); - yield return selector(xs, 1, new int?[] { null, null, null, null, 0 }); - yield return selector(xs, 2, new int?[] { null, null, null, 1, 0 }); - yield return selector(xs, 3, new int?[] { null, null, 2, 1, 0 }); - yield return selector(xs, 4, new int?[] { null, 3, 2, 1, 0 }); - yield return selector(xs, 5, new int?[] { 4, 3, 2, 1, 0 }); - yield return selector(xs, 6, new int?[] { 4, 3, 2, 1, 0 }); - yield return selector(xs, 7, new int?[] { 4, 3, 2, 1, 0 }); + yield return selector(xs, -1, [null, null, null, null, null]); + yield return selector(xs, 0, [null, null, null, null, null]); + yield return selector(xs, 1, [null, null, null, null, 0]); + yield return selector(xs, 2, [null, null, null, 1, 0]); + yield return selector(xs, 3, [null, null, 2, 1, 0]); + yield return selector(xs, 4, [null, 3, 2, 1, 0]); + yield return selector(xs, 5, [4, 3, 2, 1, 0]); + yield return selector(xs, 6, [4, 3, 2, 1, 0]); + yield return selector(xs, 7, [4, 3, 2, 1, 0]); } static readonly IEnumerable SequenceData = @@ -170,14 +170,11 @@ public IEnumerator GetEnumerator() => /// enumerator to be substituted for another. /// - sealed class Collection : Sequence, ICollection + sealed class Collection(ICollection collection, + Func, IEnumerator>? em = null) : + Sequence(em), ICollection { - readonly ICollection _collection; - - public Collection(ICollection collection, - Func, IEnumerator>? em = null) : - base(em) => - _collection = collection ?? throw new ArgumentNullException(nameof(collection)); + readonly ICollection _collection = collection ?? throw new ArgumentNullException(nameof(collection)); public int Count => _collection.Count; public bool IsReadOnly => _collection.IsReadOnly; @@ -197,14 +194,11 @@ public Collection(ICollection collection, /// also permits its enumerator to be substituted for another. /// - sealed class ReadOnlyCollection : Sequence, IReadOnlyCollection + sealed class ReadOnlyCollection(ICollection collection, + Func, IEnumerator>? em = null) : + Sequence(em), IReadOnlyCollection { - readonly ICollection _collection; - - public ReadOnlyCollection(ICollection collection, - Func, IEnumerator>? em = null) : - base(em) => - _collection = collection ?? throw new ArgumentNullException(nameof(collection)); + readonly ICollection _collection = collection ?? throw new ArgumentNullException(nameof(collection)); public int Count => _collection.Count; diff --git a/MoreLinq.Test/DistinctByTest.cs b/MoreLinq.Test/DistinctByTest.cs index 70c684592..d78c4614e 100644 --- a/MoreLinq.Test/DistinctByTest.cs +++ b/MoreLinq.Test/DistinctByTest.cs @@ -27,7 +27,7 @@ public class DistinctByTest [Test] public void DistinctBy() { - string[] source = { "first", "second", "third", "fourth", "fifth" }; + string[] source = ["first", "second", "third", "fourth", "fifth"]; var distinct = source.DistinctBy(word => word.Length); distinct.AssertSequenceEqual("first", "second"); } @@ -41,7 +41,7 @@ public void DistinctByIsLazy() [Test] public void DistinctByWithComparer() { - string[] source = { "first", "FIRST", "second", "second", "third" }; + string[] source = ["first", "FIRST", "second", "second", "third"]; var distinct = source.DistinctBy(word => word, StringComparer.OrdinalIgnoreCase); distinct.AssertSequenceEqual("first", "second", "third"); } @@ -49,7 +49,7 @@ public void DistinctByWithComparer() [Test] public void DistinctByNullComparer() { - string[] source = { "first", "second", "third", "fourth", "fifth" }; + string[] source = ["first", "second", "third", "fourth", "fifth"]; var distinct = source.DistinctBy(word => word.Length, null); distinct.AssertSequenceEqual("first", "second"); } diff --git a/MoreLinq.Test/ExceptByTest.cs b/MoreLinq.Test/ExceptByTest.cs index 43c3fa1a1..1935e0793 100644 --- a/MoreLinq.Test/ExceptByTest.cs +++ b/MoreLinq.Test/ExceptByTest.cs @@ -26,8 +26,8 @@ public class ExceptByTest [Test] public void SimpleExceptBy() { - string[] first = { "aaa", "bb", "c", "dddd" }; - string[] second = { "xx", "y" }; + string[] first = ["aaa", "bb", "c", "dddd"]; + string[] second = ["xx", "y"]; var result = first.ExceptBy(second, x => x.Length); result.AssertSequenceEqual("aaa", "dddd"); } @@ -42,8 +42,8 @@ public void ExceptByIsLazy() [Test] public void ExceptByDoesNotRepeatSourceElementsWithDuplicateKeys() { - string[] first = { "aaa", "bb", "c", "a", "b", "c", "dddd" }; - string[] second = { "xx" }; + string[] first = ["aaa", "bb", "c", "a", "b", "c", "dddd"]; + string[] second = ["xx"]; var result = first.ExceptBy(second, x => x.Length); result.AssertSequenceEqual("aaa", "c", "dddd"); } @@ -51,8 +51,8 @@ public void ExceptByDoesNotRepeatSourceElementsWithDuplicateKeys() [Test] public void ExceptByWithComparer() { - string[] first = { "first", "second", "third", "fourth" }; - string[] second = { "FIRST", "thiRD", "FIFTH" }; + string[] first = ["first", "second", "third", "fourth"]; + string[] second = ["FIRST", "thiRD", "FIFTH"]; var result = first.ExceptBy(second, word => word, StringComparer.OrdinalIgnoreCase); result.AssertSequenceEqual("second", "fourth"); } @@ -60,8 +60,8 @@ public void ExceptByWithComparer() [Test] public void ExceptByNullComparer() { - string[] first = { "aaa", "bb", "c", "dddd" }; - string[] second = { "xx", "y" }; + string[] first = ["aaa", "bb", "c", "dddd"]; + string[] second = ["xx", "y"]; var result = first.ExceptBy(second, x => x.Length, null); result.AssertSequenceEqual("aaa", "dddd"); } diff --git a/MoreLinq.Test/FlattenTest.cs b/MoreLinq.Test/FlattenTest.cs index f08a8f6fb..0ad6fd3a8 100644 --- a/MoreLinq.Test/FlattenTest.cs +++ b/MoreLinq.Test/FlattenTest.cs @@ -309,19 +309,19 @@ public void FlattenSelector() new Series { Name = "series1", - Attributes = new[] - { - new Attribute { Values = new[] { 1, 2 } }, - new Attribute { Values = new[] { 3, 4 } }, - } + Attributes = + [ + new Attribute { Values = [1, 2] }, + new Attribute { Values = [3, 4] }, + ] }, new Series { Name = "series2", - Attributes = new[] - { - new Attribute { Values = new[] { 5, 6 } }, - } + Attributes = + [ + new Attribute { Values = [5, 6] }, + ] } }; @@ -416,19 +416,9 @@ sealed class Attribute public required int[] Values; } - sealed class Tree + sealed record Tree(Tree? Left, T Value, Tree? Right) { - public readonly T Value; - public readonly Tree? Left; - public readonly Tree? Right; - public Tree(T value) : this(null, value, null) { } - public Tree(Tree? left, T value, Tree? right) - { - Left = left; - Value = value; - Right = right; - } } } } diff --git a/MoreLinq.Test/GroupAdjacentTest.cs b/MoreLinq.Test/GroupAdjacentTest.cs index b3830a2d2..223d60474 100644 --- a/MoreLinq.Test/GroupAdjacentTest.cs +++ b/MoreLinq.Test/GroupAdjacentTest.cs @@ -207,7 +207,7 @@ public void GroupAdjacentSourceSequenceWithSomeNullKeys() .SelectMany(x => Enumerable.Repeat((int?)x, x).Append(null)) .GroupAdjacent(x => x); - int?[] aNull = { null }; + int?[] aNull = [null]; using var reader = groupings.Read(); AssertGrouping(reader, 1, 1); diff --git a/MoreLinq.Test/PermutationsTest.cs b/MoreLinq.Test/PermutationsTest.cs index 892d3ea9b..44571c6fa 100644 --- a/MoreLinq.Test/PermutationsTest.cs +++ b/MoreLinq.Test/PermutationsTest.cs @@ -78,15 +78,15 @@ public void TestCardinalityThreePermutation() var set = new[] { 42, 11, 100 }; var permutations = set.Permutations(); - var expectedPermutations = new[] - { - new[] {42, 11, 100}, - new[] {42, 100, 11}, - new[] {11, 100, 42}, - new[] {11, 42, 100}, - new[] {100, 11, 42}, - new[] {100, 42, 11}, - }; + var expectedPermutations = new int[][] + { + [42, 11, 100], + [42, 100, 11], + [11, 100, 42], + [11, 42, 100], + [100, 11, 42], + [100, 42, 11], + }; // should contain six permutations (as defined above) Assert.That(permutations.Count(), Is.EqualTo(expectedPermutations.Length)); @@ -103,33 +103,33 @@ public void TestCardinalityFourPermutation() var set = new[] { 42, 11, 100, 89 }; var permutations = set.Permutations(); - var expectedPermutations = new[] - { - new[] {42, 11, 100, 89}, - new[] {42, 100, 11, 89}, - new[] {11, 100, 42, 89}, - new[] {11, 42, 100, 89}, - new[] {100, 11, 42, 89}, - new[] {100, 42, 11, 89}, - new[] {42, 11, 89, 100}, - new[] {42, 100, 89, 11}, - new[] {11, 100, 89, 42}, - new[] {11, 42, 89, 100}, - new[] {100, 11, 89, 42}, - new[] {100, 42, 89, 11}, - new[] {42, 89, 11, 100}, - new[] {42, 89, 100, 11}, - new[] {11, 89, 100, 42}, - new[] {11, 89, 42, 100}, - new[] {100, 89, 11, 42}, - new[] {100, 89, 42, 11}, - new[] {89, 42, 11, 100}, - new[] {89, 42, 100, 11}, - new[] {89, 11, 100, 42}, - new[] {89, 11, 42, 100}, - new[] {89, 100, 11, 42}, - new[] {89, 100, 42, 11}, - }; + var expectedPermutations = new int[][] + { + [42, 11, 100, 89], + [42, 100, 11, 89], + [11, 100, 42, 89], + [11, 42, 100, 89], + [100, 11, 42, 89], + [100, 42, 11, 89], + [42, 11, 89, 100], + [42, 100, 89, 11], + [11, 100, 89, 42], + [11, 42, 89, 100], + [100, 11, 89, 42], + [100, 42, 89, 11], + [42, 89, 11, 100], + [42, 89, 100, 11], + [11, 89, 100, 42], + [11, 89, 42, 100], + [100, 89, 11, 42], + [100, 89, 42, 11], + [89, 42, 11, 100], + [89, 42, 100, 11], + [89, 11, 100, 42], + [89, 11, 42, 100], + [89, 100, 11, 42], + [89, 100, 42, 11], + }; // should contain six permutations (as defined above) Assert.That(permutations.Count(), Is.EqualTo(expectedPermutations.Length)); diff --git a/MoreLinq.Test/PrependTest.cs b/MoreLinq.Test/PrependTest.cs index de8253f6e..00d5bf982 100644 --- a/MoreLinq.Test/PrependTest.cs +++ b/MoreLinq.Test/PrependTest.cs @@ -28,7 +28,7 @@ public class PrependTest [Test] public void PrependWithNonEmptyTailSequence() { - string[] tail = { "second", "third" }; + string[] tail = ["second", "third"]; var head = "first"; var whole = tail.Prepend(head); whole.AssertSequenceEqual("first", "second", "third"); @@ -37,7 +37,7 @@ public void PrependWithNonEmptyTailSequence() [Test] public void PrependWithEmptyTailSequence() { - string[] tail = { }; + string[] tail = []; var head = "first"; var whole = tail.Prepend(head); whole.AssertSequenceEqual("first"); @@ -46,7 +46,7 @@ public void PrependWithEmptyTailSequence() [Test] public void PrependWithNullHead() { - string[] tail = { "second", "third" }; + string[] tail = ["second", "third"]; string? head = null; var whole = tail.Prepend(head); whole.AssertSequenceEqual(null, "second", "third"); diff --git a/MoreLinq.Test/ReadOnlyCollection.cs b/MoreLinq.Test/ReadOnlyCollection.cs index 23da7f290..82004faf4 100644 --- a/MoreLinq.Test/ReadOnlyCollection.cs +++ b/MoreLinq.Test/ReadOnlyCollection.cs @@ -25,12 +25,11 @@ static class ReadOnlyCollection public static IReadOnlyCollection From(params T[] items) => new ListCollection(items); - sealed class ListCollection : IReadOnlyCollection + sealed class ListCollection(TList list) : + IReadOnlyCollection where TList : IList { - readonly TList _list; - - public ListCollection(TList list) => _list = list; + readonly TList _list = list; public IEnumerator GetEnumerator() => _list.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/MoreLinq.Test/SequenceReader.cs b/MoreLinq.Test/SequenceReader.cs index 5a2a0cba6..c49c51c3b 100644 --- a/MoreLinq.Test/SequenceReader.cs +++ b/MoreLinq.Test/SequenceReader.cs @@ -35,9 +35,14 @@ public static SequenceReader Read(this IEnumerable source) /// "read" operation. /// /// Type of elements to read. - sealed class SequenceReader : IDisposable + /// + /// Initializes a instance + /// from an enumerator. + /// + /// Source enumerator. + sealed class SequenceReader(IEnumerator enumerator) : IDisposable { - IEnumerator? _enumerator; + IEnumerator? _enumerator = enumerator ?? throw new ArgumentNullException(nameof(enumerator)); /// /// Initializes a instance @@ -48,15 +53,6 @@ sealed class SequenceReader : IDisposable public SequenceReader(IEnumerable source) : this(GetEnumerator(source)) { } - /// - /// Initializes a instance - /// from an enumerator. - /// - /// Source enumerator. - - public SequenceReader(IEnumerator enumerator) => - _enumerator = enumerator ?? throw new ArgumentNullException(nameof(enumerator)); - static IEnumerator GetEnumerator(IEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); diff --git a/MoreLinq.Test/SubsetTest.cs b/MoreLinq.Test/SubsetTest.cs index 5b35524bf..ef079e166 100644 --- a/MoreLinq.Test/SubsetTest.cs +++ b/MoreLinq.Test/SubsetTest.cs @@ -117,14 +117,14 @@ public void TestAllSubsetsExpectedResults() var sequence = Enumerable.Range(1, 4); var result = sequence.Subsets(); - var expectedSubsets = new[] - { - new int[] {}, - new[] {1}, new[] {2}, new[] {3}, new[] {4}, - new[] {1,2}, new[] {1,3}, new[] {1,4}, new[] {2,3}, new[] {2,4}, new[] {3,4}, - new[] {1,2,3}, new[] {1,2,4}, new[] {1,3,4}, new[] {2,3,4}, - new[] {1,2,3,4} - }; + var expectedSubsets = new int[][] + { + [], + [1], [2], [3], [4], + [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], + [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4], + [1, 2, 3, 4] + }; var index = 0; foreach (var subset in result) @@ -170,24 +170,24 @@ public void TestKSubsetExpectedResult() var sequence = Enumerable.Range(1, 6); var result = sequence.Subsets(4); - var expectedSubsets = new[] - { - new[] {1,2,3,4}, - new[] {1,2,3,5}, - new[] {1,2,3,6}, - new[] {1,2,4,5}, - new[] {1,2,4,6}, - new[] {1,2,5,6}, - new[] {1,3,4,5}, - new[] {1,3,4,6}, - new[] {1,3,5,6}, - new[] {1,4,5,6}, - new[] {2,3,4,5}, - new[] {2,3,4,6}, - new[] {2,3,5,6}, - new[] {2,4,5,6}, - new[] {3,4,5,6}, - }; + var expectedSubsets = new int[][] + { + [1, 2, 3, 4], + [1, 2, 3, 5], + [1, 2, 3, 6], + [1, 2, 4, 5], + [1, 2, 4, 6], + [1, 2, 5, 6], + [1, 3, 4, 5], + [1, 3, 4, 6], + [1, 3, 5, 6], + [1, 4, 5, 6], + [2, 3, 4, 5], + [2, 3, 4, 6], + [2, 3, 5, 6], + [2, 4, 5, 6], + [3, 4, 5, 6], + }; var index = 0; foreach (var subset in result) diff --git a/MoreLinq.Test/TestException.cs b/MoreLinq.Test/TestException.cs index 98cb7c715..48f0cb740 100644 --- a/MoreLinq.Test/TestException.cs +++ b/MoreLinq.Test/TestException.cs @@ -21,9 +21,8 @@ namespace MoreLinq.Test /// Reserved for use within tests. /// - sealed class TestException : System.Exception + sealed class TestException(string? message) : System.Exception(message) { public TestException() : this(null) { } - public TestException(string? message) : base(message) { } } } diff --git a/MoreLinq.Test/ToDataTableTest.cs b/MoreLinq.Test/ToDataTableTest.cs index ae053830c..5842fe23a 100644 --- a/MoreLinq.Test/ToDataTableTest.cs +++ b/MoreLinq.Test/ToDataTableTest.cs @@ -27,26 +27,17 @@ namespace MoreLinq.Test [TestFixture] public class ToDataTableTest { - sealed class TestObject + sealed class TestObject(int key) { - public int KeyField; - public Guid? ANullableGuidField; + public int KeyField = key; + public Guid? ANullableGuidField = Guid.NewGuid(); - public string AString { get; } - public decimal? ANullableDecimal { get; } + public string AString { get; } = "ABCDEFGHIKKLMNOPQRSTUVWXYSZ"; + public decimal? ANullableDecimal { get; } = key / 3; public object Unreadable { set => throw new NotImplementedException(); } public object this[int index] { get => new(); set { } } - public TestObject(int key) - { - KeyField = key; - ANullableGuidField = Guid.NewGuid(); - - ANullableDecimal = key / 3; - AString = "ABCDEFGHIKKLMNOPQRSTUVWXYSZ"; - } - public override string ToString() => nameof(TestObject); } diff --git a/MoreLinq.Test/TransposeTest.cs b/MoreLinq.Test/TransposeTest.cs index 826e55687..2e1cf417d 100644 --- a/MoreLinq.Test/TransposeTest.cs +++ b/MoreLinq.Test/TransposeTest.cs @@ -45,12 +45,12 @@ public void TransposeWithOneNullRow() [Test] public void TransposeWithRowsOfSameLength() { - var expectations = new[] + var expectations = new int[][] { - new [] { 10, 20, 30 }, - new [] { 11, 21, 31 }, - new [] { 12, 22, 32 }, - new [] { 13, 23, 33 }, + [10, 20, 30], + [11, 21, 31], + [12, 22, 32], + [13, 23, 33], }; using var row1 = TestingSequence.Of(10, 11, 12, 13); @@ -64,11 +64,11 @@ public void TransposeWithRowsOfSameLength() [Test] public void TransposeWithRowsOfDifferentLengths() { - var expectations = new[] + var expectations = new int[][] { - new[] { 10, 20, 30 }, - new[] { 11, 31 }, - new[] { 32 } + [10, 20, 30], + [11, 31], + [32] }; using var row1 = TestingSequence.Of(10, 11); @@ -85,10 +85,10 @@ public void TransposeMaintainsCornerElements() { var matrix = new[] { - new[] { 10, 11 }, - new[] { 20 }, + [10, 11], + [20], new int[0], - new[] { 30, 31, 32 } + [30, 31, 32] }; var traspose = matrix.Transpose(); @@ -107,13 +107,13 @@ public void TransposeWithAllRowsAsInfiniteSequences() var result = matrix.Transpose().Take(5); - var expectations = new[] + var expectations = new int[][] { - new[] { 2, 3, 5 }, - new[] { 4, 9, 25 }, - new[] { 8, 27, 125 }, - new[] { 16, 81, 625 }, - new[] { 32, 243, 3125 } + [2, 3, 5], + [4, 9, 25], + [8, 27, 125], + [16, 81, 625], + [32, 243, 3125] }; AssertMatrix(expectations, result); @@ -130,13 +130,13 @@ public void TransposeWithSomeRowsAsInfiniteSequences() var result = matrix.Transpose().Take(5); - var expectations = new[] + var expectations = new int[][] { - new[] { 2, 3, 5 }, - new[] { 4, 9, 25 }, - new[] { 8, 125 }, - new[] { 16, 625 }, - new[] { 32, 3125 } + [2, 3, 5], + [4, 9, 25], + [8, 125], + [16, 625], + [32, 3125] }; AssertMatrix(expectations, result); @@ -147,10 +147,10 @@ public void TransposeColumnTraversalOrderIsIrrelevant() { var matrix = new[] { - new[] { 10, 11 }, - new[] { 20 }, + [10, 11], + [20], new int[0], - new[] { 30, 31, 32 } + [30, 31, 32] }; var transpose = matrix.Transpose().ToList(); diff --git a/MoreLinq.Test/TraverseTest.cs b/MoreLinq.Test/TraverseTest.cs index 163b3b401..89a0b2277 100644 --- a/MoreLinq.Test/TraverseTest.cs +++ b/MoreLinq.Test/TraverseTest.cs @@ -50,16 +50,10 @@ public void TraverseBreadthFirstPreservesChildrenOrder() res.AssertSequenceEqual(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); } - sealed class Tree + sealed class Tree(T value, IEnumerable> children) { - public T Value { get; } - public IEnumerable> Children { get; } - - public Tree(T value, IEnumerable> children) - { - Value = value; - Children = children; - } + public T Value { get; } = value; + public IEnumerable> Children { get; } = children; } static class Tree diff --git a/MoreLinq.Test/TrySingleTest.cs b/MoreLinq.Test/TrySingleTest.cs index 45186c623..01b12b313 100644 --- a/MoreLinq.Test/TrySingleTest.cs +++ b/MoreLinq.Test/TrySingleTest.cs @@ -65,10 +65,10 @@ public void TrySingleWithSingletonCollection(IEnumerable source, T result) } static readonly ITestCaseData[] SingletonCollectionTestCases = - { + [ new TestCaseData(new BreakingSingleElementCollection(10), 10), new TestCaseData(new BreakingSingleElementReadOnlyCollection(20), 20) - }; + ]; class BreakingSingleElementCollectionBase : IEnumerable { @@ -89,11 +89,10 @@ public IEnumerator GetEnumerator() IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } - sealed class BreakingSingleElementCollection : - BreakingSingleElementCollectionBase, ICollection + sealed class BreakingSingleElementCollection(T element) : + BreakingSingleElementCollectionBase(element), + ICollection { - public BreakingSingleElementCollection(T element) : base(element) { } - public void Add(T item) => throw new NotImplementedException(); public void Clear() => throw new NotImplementedException(); public bool Contains(T item) => throw new NotImplementedException(); @@ -102,10 +101,9 @@ public BreakingSingleElementCollection(T element) : base(element) { } public bool IsReadOnly => true; } - sealed class BreakingSingleElementReadOnlyCollection : - BreakingSingleElementCollectionBase, IReadOnlyCollection + sealed class BreakingSingleElementReadOnlyCollection(T element) : + BreakingSingleElementCollectionBase(element), IReadOnlyCollection { - public BreakingSingleElementReadOnlyCollection(T element) : base(element) { } } [TestCase(SourceKind.Sequence)] diff --git a/MoreLinq.Test/WatchableEnumerator.cs b/MoreLinq.Test/WatchableEnumerator.cs index 4cb3d4221..2d782604d 100644 --- a/MoreLinq.Test/WatchableEnumerator.cs +++ b/MoreLinq.Test/WatchableEnumerator.cs @@ -26,17 +26,15 @@ partial class TestExtensions public static WatchableEnumerator AsWatchable(this IEnumerator source) => new(source); } - sealed class WatchableEnumerator : IEnumerator + sealed class WatchableEnumerator(IEnumerator source) : + IEnumerator { - readonly IEnumerator _source; + readonly IEnumerator _source = source ?? throw new ArgumentNullException(nameof(source)); public event EventHandler? Disposed; public event EventHandler? GetCurrentCalled; public event EventHandler? MoveNextCalled; - public WatchableEnumerator(IEnumerator source) => - _source = source ?? throw new ArgumentNullException(nameof(source)); - public T Current { get diff --git a/MoreLinq/Acquire.cs b/MoreLinq/Acquire.cs index d7e44900f..6b3d47121 100644 --- a/MoreLinq/Acquire.cs +++ b/MoreLinq/Acquire.cs @@ -47,7 +47,7 @@ public static TSource[] Acquire(this IEnumerable source) try { disposables.AddRange(source); - return disposables.ToArray(); + return [..disposables]; } catch { diff --git a/MoreLinq/Collections/Dictionary.cs b/MoreLinq/Collections/Dictionary.cs index a325768d8..f79b23104 100644 --- a/MoreLinq/Collections/Dictionary.cs +++ b/MoreLinq/Collections/Dictionary.cs @@ -49,13 +49,11 @@ public TValue this[TKey key] public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) => _dict.TryGetValue(ValueTuple.Create(key), out value); - sealed class ValueTupleItemComparer : IEqualityComparer> + sealed class ValueTupleItemComparer(IEqualityComparer comparer) : + IEqualityComparer> { - readonly IEqualityComparer _comparer; - - public ValueTupleItemComparer(IEqualityComparer comparer) => _comparer = comparer; - public bool Equals(ValueTuple x, ValueTuple y) => _comparer.Equals(x.Item1, y.Item1); - public int GetHashCode(ValueTuple obj) => obj.Item1 is { } some ? _comparer.GetHashCode(some) : 0; + public bool Equals(ValueTuple x, ValueTuple y) => comparer.Equals(x.Item1, y.Item1); + public int GetHashCode(ValueTuple obj) => obj.Item1 is { } some ? comparer.GetHashCode(some) : 0; } } } diff --git a/MoreLinq/CountBy.cs b/MoreLinq/CountBy.cs index 282ace5d4..c1f8873ed 100644 --- a/MoreLinq/CountBy.cs +++ b/MoreLinq/CountBy.cs @@ -80,8 +80,8 @@ void Loop(IEqualityComparer cmp) { var dic = new Collections.Dictionary(cmp); - keys = new List(); - counts = new List(); + keys = []; + counts = []; foreach (var item in source) { diff --git a/MoreLinq/Delegating.cs b/MoreLinq/Delegating.cs index 9b427e6c5..81c9ada81 100644 --- a/MoreLinq/Delegating.cs +++ b/MoreLinq/Delegating.cs @@ -40,12 +40,9 @@ public static IObserver Observer(Action onNext, new DelegatingObserver(onNext, onError, onCompleted); } - sealed class DelegatingDisposable : IDisposable + sealed class DelegatingDisposable(Action delegatee) : IDisposable { - Action? _delegatee; - - public DelegatingDisposable(Action delegatee) => - _delegatee = delegatee ?? throw new ArgumentNullException(nameof(delegatee)); + Action? _delegatee = delegatee ?? throw new ArgumentNullException(nameof(delegatee)); public void Dispose() { @@ -56,23 +53,15 @@ public void Dispose() } } - sealed class DelegatingObserver : IObserver + sealed class DelegatingObserver(Action onNext, + Action? onError = null, + Action? onCompleted = null) : + IObserver { - readonly Action _onNext; - readonly Action? _onError; - readonly Action? _onCompleted; - - public DelegatingObserver(Action onNext, - Action? onError = null, - Action? onCompleted = null) - { - _onNext = onNext ?? throw new ArgumentNullException(nameof(onNext)); - _onError = onError; - _onCompleted = onCompleted; - } + readonly Action _onNext = onNext ?? throw new ArgumentNullException(nameof(onNext)); - public void OnCompleted() => _onCompleted?.Invoke(); - public void OnError(Exception error) => _onError?.Invoke(error); + public void OnCompleted() => onCompleted?.Invoke(); + public void OnError(Exception error) => onError?.Invoke(error); public void OnNext(T value) => _onNext(value); } } diff --git a/MoreLinq/EmptyArray.cs b/MoreLinq/EmptyArray.cs deleted file mode 100644 index fa49b3567..000000000 --- a/MoreLinq/EmptyArray.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace MoreLinq -{ - static class EmptyArray - { - public static readonly T[] Value = -#if NETSTANDARD1_6_OR_GREATER || NET6_0_OR_GREATER - System.Array.Empty(); -#else -#pragma warning disable CA1825 // Avoid zero-length array allocations - new T[0]; -#pragma warning restore CA1825 // Avoid zero-length array allocations -#endif - } -} diff --git a/MoreLinq/EquiZip.cs b/MoreLinq/EquiZip.cs index 61212f122..7417e17e2 100644 --- a/MoreLinq/EquiZip.cs +++ b/MoreLinq/EquiZip.cs @@ -201,7 +201,7 @@ static IEnumerable EquiZipImpl( } static readonly string[] OrdinalNumbers = - { + [ "First", "Second", "Third", @@ -218,6 +218,6 @@ static IEnumerable EquiZipImpl( // "Fourteenth", // "Fifteenth", // "Sixteenth", - }; + ]; } } diff --git a/MoreLinq/Experimental/Async/Merge.cs b/MoreLinq/Experimental/Async/Merge.cs index 7e6312b9b..72c9a459c 100644 --- a/MoreLinq/Experimental/Async/Merge.cs +++ b/MoreLinq/Experimental/Async/Merge.cs @@ -107,7 +107,7 @@ async IAsyncEnumerable Async([EnumeratorCancellation]CancellationToken cancel enumeratorList.AddRange(from s in sources select s.GetAsyncEnumerator(cancellationToken)); - pendingTaskList = new List)>>(); + pendingTaskList = []; const bool some = true; @@ -117,7 +117,7 @@ async IAsyncEnumerable Async([EnumeratorCancellation]CancellationToken cancel var disposalTask = enumerator.DisposeAsync(); if (disposalTask.IsCompleted) return disposalTask; - disposalTaskList ??= new List(); + disposalTaskList ??= []; disposalTaskList.Add(disposalTask.AsTask()); return null; } @@ -232,7 +232,7 @@ async IAsyncEnumerable Async([EnumeratorCancellation]CancellationToken cancel } else { - disposalTaskList ??= new List(); + disposalTaskList ??= []; disposalTaskList.Add(task.AsTask()); } } diff --git a/MoreLinq/Experimental/Await.cs b/MoreLinq/Experimental/Await.cs index abbfa0caa..c7d1919f6 100644 --- a/MoreLinq/Experimental/Await.cs +++ b/MoreLinq/Experimental/Await.cs @@ -705,26 +705,18 @@ public static IAwaitQuery new AwaitQuery(impl, options); } - sealed class AwaitQuery : IAwaitQuery + sealed class AwaitQuery(Func> impl, + AwaitQueryOptions? options = null) : IAwaitQuery { - readonly Func> _impl; - - public AwaitQuery(Func> impl, - AwaitQueryOptions? options = null) - { - _impl = impl; - Options = options ?? AwaitQueryOptions.Default; - } - - public AwaitQueryOptions Options { get; } + public AwaitQueryOptions Options { get; } = options ?? AwaitQueryOptions.Default; public IAwaitQuery WithOptions(AwaitQueryOptions options) { if (options == null) throw new ArgumentNullException(nameof(options)); - return Options == options ? this : new AwaitQuery(_impl, options); + return Options == options ? this : new AwaitQuery(impl, options); } - public IEnumerator GetEnumerator() => _impl(Options).GetEnumerator(); + public IEnumerator GetEnumerator() => impl(Options).GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/MoreLinq/Experimental/Batch.cs b/MoreLinq/Experimental/Batch.cs index ee25e1619..f4cae14be 100644 --- a/MoreLinq/Experimental/Batch.cs +++ b/MoreLinq/Experimental/Batch.cs @@ -229,7 +229,7 @@ ICurrentBufferProvider Cursor(IEnumerator<(T[], int)> source) => sealed class CurrentPoolArrayProvider : CurrentBuffer, ICurrentBufferProvider { bool _rented; - T[] _array = Array.Empty(); + T[] _array = []; int _count; IEnumerator<(T[], int)>? _rental; ArrayPool? _pool; @@ -280,7 +280,7 @@ public void Dispose() if (_rented) _pool.Return(array); enumerator.Dispose(); - _array = Array.Empty(); + _array = []; _count = 0; _rental = null; _pool = null; diff --git a/MoreLinq/Experimental/Memoize.cs b/MoreLinq/Experimental/Memoize.cs index 258037e9c..d7ee0f7ab 100644 --- a/MoreLinq/Experimental/Memoize.cs +++ b/MoreLinq/Experimental/Memoize.cs @@ -62,21 +62,15 @@ public static IEnumerable Memoize(this IEnumerable source) => }; } - sealed class MemoizedEnumerable : IEnumerable, IDisposable + sealed class MemoizedEnumerable(IEnumerable sequence) : IEnumerable, IDisposable { List? _cache; - readonly object _locker; - readonly IEnumerable _source; + readonly object _locker = new(); + readonly IEnumerable _source = sequence ?? throw new ArgumentNullException(nameof(sequence)); IEnumerator? _sourceEnumerator; int? _errorIndex; ExceptionDispatchInfo? _error; - public MemoizedEnumerable(IEnumerable sequence) - { - _source = sequence ?? throw new ArgumentNullException(nameof(sequence)); - _locker = new object(); - } - public IEnumerator GetEnumerator() { if (_cache == null) diff --git a/MoreLinq/FillBackward.cs b/MoreLinq/FillBackward.cs index c07c8a81b..639f1d450 100644 --- a/MoreLinq/FillBackward.cs +++ b/MoreLinq/FillBackward.cs @@ -114,7 +114,7 @@ static IEnumerable FillBackwardImpl(IEnumerable source, Func p var isBlank = predicate(item); if (isBlank) { - (blanks ??= new List()).Add(item); + (blanks ??= []).Add(item); } else { diff --git a/MoreLinq/GroupAdjacent.cs b/MoreLinq/GroupAdjacent.cs index 8cf89a5e3..fe6043f82 100644 --- a/MoreLinq/GroupAdjacent.cs +++ b/MoreLinq/GroupAdjacent.cs @@ -305,19 +305,12 @@ public static Grouping Create(TKey key, IEnumera } [Serializable] - sealed class Grouping : IGrouping + sealed class Grouping(TKey key, IEnumerable members) : + IGrouping { - readonly IEnumerable _members; + public TKey Key { get; } = key; - public Grouping(TKey key, IEnumerable members) - { - Key = key; - _members = members; - } - - public TKey Key { get; } - - public IEnumerator GetEnumerator() => _members.GetEnumerator(); + public IEnumerator GetEnumerator() => members.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } diff --git a/MoreLinq/Maxima.cs b/MoreLinq/Maxima.cs index 60150a433..d5262251b 100644 --- a/MoreLinq/Maxima.cs +++ b/MoreLinq/Maxima.cs @@ -218,21 +218,13 @@ public static IExtremaEnumerable Maxima(this IEnumerable return new ExtremaEnumerable(source, selector, comparer.Compare); } - sealed class ExtremaEnumerable : IExtremaEnumerable + sealed class ExtremaEnumerable(IEnumerable source, + Func selector, + Func comparer) : + IExtremaEnumerable { - readonly IEnumerable _source; - readonly Func _selector; - readonly Func _comparer; - - public ExtremaEnumerable(IEnumerable source, Func selector, Func comparer) - { - _source = source; - _selector = selector; - _comparer = comparer; - } - public IEnumerator GetEnumerator() => - ExtremaBy(_source, Extrema.First, null, _selector, _comparer).GetEnumerator(); + ExtremaBy(source, Extrema.First, null, selector, comparer).GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); @@ -241,16 +233,16 @@ public IEnumerable Take(int count) => count switch { 0 => Enumerable.Empty(), - 1 => ExtremaBy(_source, Extremum.First, 1 , _selector, _comparer), - _ => ExtremaBy(_source, Extrema.First , count, _selector, _comparer) + 1 => ExtremaBy(source, Extremum.First, 1 , selector, comparer), + _ => ExtremaBy(source, Extrema.First , count, selector, comparer) }; public IEnumerable TakeLast(int count) => count switch { 0 => Enumerable.Empty(), - 1 => ExtremaBy(_source, Extremum.Last, 1 , _selector, _comparer), - _ => ExtremaBy(_source, Extrema.Last , count, _selector, _comparer) + 1 => ExtremaBy(source, Extremum.Last, 1 , selector, comparer), + _ => ExtremaBy(source, Extrema.Last , count, selector, comparer) }; static class Extrema @@ -267,7 +259,7 @@ sealed class FirstExtrema : Extrema?, T> public override void Add(ref List? store, int? limit, T item) { if (limit == null || store is null || store.Count < limit) - (store ??= new List()).Add(item); + (store ??= []).Add(item); } } diff --git a/MoreLinq/Partition.cs b/MoreLinq/Partition.cs index aa72f8725..9660186fc 100644 --- a/MoreLinq/Partition.cs +++ b/MoreLinq/Partition.cs @@ -367,7 +367,7 @@ static TResult PartitionImpl(IEnumerable>(); + etc ??= []; etc.Add(e); } else diff --git a/MoreLinq/PendNode.cs b/MoreLinq/PendNode.cs index 2bf363863..9c3e4e5f5 100644 --- a/MoreLinq/PendNode.cs +++ b/MoreLinq/PendNode.cs @@ -53,10 +53,9 @@ public Item(T item, bool isPrepend, PendNode next) } } - sealed class Source : PendNode + sealed class Source(IEnumerable source) : PendNode { - public IEnumerable Value { get; } - public Source(IEnumerable source) => Value = source; + public IEnumerable Value { get; } = source; } public IEnumerator GetEnumerator() diff --git a/MoreLinq/Reactive/Subject.cs b/MoreLinq/Reactive/Subject.cs index 145282cf0..40f2ed6d2 100644 --- a/MoreLinq/Reactive/Subject.cs +++ b/MoreLinq/Reactive/Subject.cs @@ -28,7 +28,7 @@ sealed class Subject : IObservable, IObserver Exception? _error; bool HasObservers => (_observers?.Count ?? 0) > 0; - List> Observers => _observers ??= new List>(); + List> Observers => _observers ??= []; bool IsMuted => _completed || _error != null; diff --git a/MoreLinq/Return.cs b/MoreLinq/Return.cs index 35ffa3adc..078d5beb7 100644 --- a/MoreLinq/Return.cs +++ b/MoreLinq/Return.cs @@ -32,11 +32,9 @@ partial class MoreEnumerable public static IEnumerable Return(T item) => new SingleElementList(item); - sealed class SingleElementList : IList, IReadOnlyList + sealed class SingleElementList(T item) : IList, IReadOnlyList { - readonly T _item; - - public SingleElementList(T item) => _item = item; + readonly T _item = item; public int Count => 1; public bool IsReadOnly => true; diff --git a/MoreLinq/ReverseComparer.cs b/MoreLinq/ReverseComparer.cs index 63fbf527f..e80749bcd 100644 --- a/MoreLinq/ReverseComparer.cs +++ b/MoreLinq/ReverseComparer.cs @@ -19,12 +19,9 @@ namespace MoreLinq { using System.Collections.Generic; - sealed class ReverseComparer : IComparer + sealed class ReverseComparer(IComparer? underlying) : IComparer { - readonly IComparer _underlying; - - public ReverseComparer(IComparer? underlying) => - _underlying = underlying ?? Comparer.Default; + readonly IComparer _underlying = underlying ?? Comparer.Default; public int Compare #if NETCOREAPP3_1_OR_GREATER diff --git a/MoreLinq/Segment.cs b/MoreLinq/Segment.cs index 788aa3ae7..859f59014 100644 --- a/MoreLinq/Segment.cs +++ b/MoreLinq/Segment.cs @@ -95,7 +95,7 @@ public static IEnumerable> Segment(this IEnumerable source, if (newSegmentPredicate(current, previous, index)) { yield return segment; // yield the completed segment - segment = new List { current }; // start a new segment + segment = [current]; // start a new segment } else // not a new segment, append and continue { diff --git a/MoreLinq/SequenceException.cs b/MoreLinq/SequenceException.cs index 6c5088984..11ac75b31 100644 --- a/MoreLinq/SequenceException.cs +++ b/MoreLinq/SequenceException.cs @@ -52,7 +52,9 @@ public SequenceException(string? message) : /// A message that describes the error. /// The exception that is the cause of the current exception. +#pragma warning disable IDE0290 // Use primary constructor (needed due to deserialization constructor) public SequenceException(string? message, Exception? innerException) : +#pragma warning restore IDE0290 // Use primary constructor base(string.IsNullOrEmpty(message) ? DefaultMessage : message, innerException) { } } } diff --git a/MoreLinq/SortedMerge.cs b/MoreLinq/SortedMerge.cs index 9f6aff425..03757dcb5 100644 --- a/MoreLinq/SortedMerge.cs +++ b/MoreLinq/SortedMerge.cs @@ -156,12 +156,9 @@ IEnumerable Impl(IEnumerable> sequences) /// are disposed - either when Excluded or when the DisposableGroup is disposed. /// - sealed class DisposableGroup : IDisposable + sealed class DisposableGroup(IEnumerable> iterators) : IDisposable { - public DisposableGroup(IEnumerable> iterators) => - Iterators = new List>(iterators); - - public List> Iterators { get; } + public List> Iterators { get; } = new(iterators); public IEnumerator this[int index] => Iterators[index]; diff --git a/MoreLinq/Split.cs b/MoreLinq/Split.cs index 1e101be66..935537aa5 100644 --- a/MoreLinq/Split.cs +++ b/MoreLinq/Split.cs @@ -287,7 +287,7 @@ public static IEnumerable Split(this IEnumerable(); + items ??= []; items.Add(item); } } diff --git a/MoreLinq/ToArrayByIndex.cs b/MoreLinq/ToArrayByIndex.cs index ce7c5917f..b450d0be5 100644 --- a/MoreLinq/ToArrayByIndex.cs +++ b/MoreLinq/ToArrayByIndex.cs @@ -122,7 +122,7 @@ public static TResult[] ToArrayByIndex(this IEnumerable source, var lastIndex = -1; var indexed = (List>?)null; - List> Indexed() => indexed ??= new List>(); + List> Indexed() => indexed ??= []; foreach (var e in source) { @@ -143,7 +143,7 @@ public static TResult[] ToArrayByIndex(this IEnumerable source, var length = lastIndex + 1; return length == 0 - ? EmptyArray.Value + ? [] : Indexed().ToArrayByIndex(length, e => e.Key, e => resultSelector(e.Value, e.Key)); } diff --git a/MoreLinq/ToDataTable.cs b/MoreLinq/ToDataTable.cs index 08027567c..ba2275956 100644 --- a/MoreLinq/ToDataTable.cs +++ b/MoreLinq/ToDataTable.cs @@ -41,7 +41,7 @@ static partial class MoreEnumerable public static TTable ToDataTable(this IEnumerable source, TTable table) where TTable : DataTable { - return ToDataTable(source, table, EmptyArray>>.Value); + return ToDataTable(source, table, []); } /// diff --git a/bld/ExtensionsGenerator/Program.cs b/bld/ExtensionsGenerator/Program.cs index 762eae7e7..35dae759d 100644 --- a/bld/ExtensionsGenerator/Program.cs +++ b/bld/ExtensionsGenerator/Program.cs @@ -380,9 +380,8 @@ protected static int Compare(IEnumerable a, IEnumerable b) => .FirstOrDefault(e => e != 0); } -sealed class SimpleTypeKey : TypeKey +sealed class SimpleTypeKey(string name) : TypeKey(name) { - public SimpleTypeKey(string name) : base(name) { } public override string ToString() => Name; public override ImmutableList Parameters => ImmutableList.Empty; } @@ -390,7 +389,7 @@ public SimpleTypeKey(string name) : base(name) { } abstract class ParameterizedTypeKey : TypeKey { protected ParameterizedTypeKey(string name, TypeKey parameter) : - this(name, ImmutableList.Create(parameter)) { } + this(name, [parameter]) { } protected ParameterizedTypeKey(string name, ImmutableList parameters) : base(name) => Parameters = parameters; @@ -398,36 +397,30 @@ protected ParameterizedTypeKey(string name, ImmutableList parameters) : public override ImmutableList Parameters { get; } } -sealed class GenericTypeKey : ParameterizedTypeKey +sealed class GenericTypeKey(string name, ImmutableList parameters) : + ParameterizedTypeKey(name, parameters) { - public GenericTypeKey(string name, ImmutableList parameters) : - base(name, parameters) { } - public override string ToString() => Name + "<" + string.Join(", ", Parameters) + ">"; } -sealed class NullableTypeKey : ParameterizedTypeKey +sealed class NullableTypeKey(TypeKey underlying) : + ParameterizedTypeKey("?", underlying) { - public NullableTypeKey(TypeKey underlying) : base("?", underlying) { } public override string ToString() => Parameters.Single() + "?"; } -sealed class TupleTypeKey : ParameterizedTypeKey +sealed class TupleTypeKey(ImmutableList parameters) : + ParameterizedTypeKey("()", parameters) { - public TupleTypeKey(ImmutableList parameters) : - base("()", parameters) { } - public override string ToString() => "(" + string.Join(", ", Parameters) + ")"; } -sealed class ArrayTypeKey : ParameterizedTypeKey +sealed class ArrayTypeKey(TypeKey element, IEnumerable ranks) : + ParameterizedTypeKey("[]", element) { - public ArrayTypeKey(TypeKey element, IEnumerable ranks) : - base("[]", element) => Ranks = ImmutableList.CreateRange(ranks); - - public ImmutableList Ranks { get; } + public ImmutableList Ranks { get; } = ImmutableList.CreateRange(ranks); public override string ToString() => Parameters.Single() + string.Concat(from r in Ranks From 84011927c09008c445dd1eb3bba81d656d6c1fec Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 18 Nov 2023 16:04:22 +0100 Subject: [PATCH 38/51] Address "Subsets" to-do about clearer members names --- MoreLinq/Subsets.cs | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/MoreLinq/Subsets.cs b/MoreLinq/Subsets.cs index 7852dd3c2..41c75eb6c 100644 --- a/MoreLinq/Subsets.cs +++ b/MoreLinq/Subsets.cs @@ -136,14 +136,12 @@ sealed class SubsetEnumerator : IEnumerator> readonly T[] _subset; // the current subset to return readonly int[] _indices; // indices into the original set - // TODO: It would be desirable to give these index members clearer names bool _continue; // termination indicator, set when all subsets have been produced - int _m; // previous swap index (upper index) - int _m2; // current swap index (lower index) - int _k; // size of the subset being produced - int _n; // size of the original set (sequence) - int _z; // count of items excluded from the subset + int _prevSwapIndex; // previous swap index (upper index) + int _currSwapIndex; // current swap index (lower index) + int _subsetSize; // size of the subset being produced + int _setSize; // size of the original set (sequence) public SubsetEnumerator(IList set, int subsetSize) { @@ -161,11 +159,10 @@ public SubsetEnumerator(IList set, int subsetSize) public void Reset() { - _m = _subset.Length; - _m2 = -1; - _k = _subset.Length; - _n = _set.Count; - _z = _n - _k + 1; + _prevSwapIndex = _subset.Length; + _currSwapIndex = -1; + _subsetSize = _subset.Length; + _setSize = _set.Count; _continue = true; } @@ -178,27 +175,29 @@ public bool MoveNext() if (!_continue) return false; - if (_m2 == -1) + if (_currSwapIndex == -1) { - _m2 = 0; - _m = _k; + _currSwapIndex = 0; + _prevSwapIndex = _subsetSize; } else { - if (_m2 < _n - _m) + if (_currSwapIndex < _setSize - _prevSwapIndex) { - _m = 0; + _prevSwapIndex = 0; } - _m++; - _m2 = _indices[_k - _m]; + _prevSwapIndex++; + _currSwapIndex = _indices[_subsetSize - _prevSwapIndex]; } - for (var j = 1; j <= _m; j++) - _indices[_k + j - _m - 1] = _m2 + j; + for (var j = 1; j <= _prevSwapIndex; j++) + _indices[_subsetSize + j - _prevSwapIndex - 1] = _currSwapIndex + j; ExtractSubset(); - _continue = _indices.Length > 0 && _indices[0] != _z; + // ........................................ count of items excluded from the subset + _continue = _indices is [var i, ..] && i != _setSize - _subsetSize + 1; + return true; } @@ -206,7 +205,7 @@ void IDisposable.Dispose() { } void ExtractSubset() { - for (var i = 0; i < _k; i++) + for (var i = 0; i < _subsetSize; i++) _subset[i] = _set[_indices[i] - 1]; } } From c0f6c10eed9f2457709b17aa506c32fadb9468c0 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sat, 18 Nov 2023 12:17:47 -0500 Subject: [PATCH 39/51] add .net8 unshipped info --- MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt index ce7910980..813e48e50 100644 --- a/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -689,3 +689,8 @@ static readonly MoreLinq.Experimental.AwaitQueryOptions.Default -> MoreLinq.Expe ~static MoreLinq.MoreEnumerable.Flatten(this System.Collections.IEnumerable! source) -> System.Collections.Generic.IEnumerable! ~static MoreLinq.MoreEnumerable.Flatten(this System.Collections.IEnumerable! source, System.Func! selector) -> System.Collections.Generic.IEnumerable! ~static MoreLinq.MoreEnumerable.Flatten(this System.Collections.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! +MoreLinq.Extensions.DuplicatesExtension +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! From 4235f51ec01fb7e5f304c9bcfb717bdbc7f49067 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sat, 18 Nov 2023 12:26:36 -0500 Subject: [PATCH 40/51] merge master and add unshipped items --- MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt index 813e48e50..057e63bee 100644 --- a/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -30,6 +30,7 @@ MoreLinq.Extensions.CountBetweenExtension MoreLinq.Extensions.CountByExtension MoreLinq.Extensions.CountDownExtension MoreLinq.Extensions.DistinctByExtension +MoreLinq.Extensions.DuplicatesExtension MoreLinq.Extensions.EndsWithExtension MoreLinq.Extensions.EquiZipExtension MoreLinq.Extensions.EvaluateExtension @@ -183,6 +184,8 @@ static MoreLinq.Extensions.CountByExtension.CountBy(this System.C static MoreLinq.Extensions.CountDownExtension.CountDown(this System.Collections.Generic.IEnumerable! source, int count, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DistinctByExtension.DistinctBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DistinctByExtension.DistinctBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.EndsWithExtension.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> bool static MoreLinq.Extensions.EndsWithExtension.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEqualityComparer? comparer) -> bool static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! @@ -441,6 +444,8 @@ static MoreLinq.MoreEnumerable.CountBy(this System.Collections.Ge static MoreLinq.MoreEnumerable.CountDown(this System.Collections.Generic.IEnumerable! source, int count, System.Func! resultSelector) -> 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.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> bool static MoreLinq.MoreEnumerable.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEqualityComparer? comparer) -> bool static MoreLinq.MoreEnumerable.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! @@ -689,8 +694,3 @@ static readonly MoreLinq.Experimental.AwaitQueryOptions.Default -> MoreLinq.Expe ~static MoreLinq.MoreEnumerable.Flatten(this System.Collections.IEnumerable! source) -> System.Collections.Generic.IEnumerable! ~static MoreLinq.MoreEnumerable.Flatten(this System.Collections.IEnumerable! source, System.Func! selector) -> System.Collections.Generic.IEnumerable! ~static MoreLinq.MoreEnumerable.Flatten(this System.Collections.IEnumerable! source, System.Func! predicate) -> System.Collections.Generic.IEnumerable! -MoreLinq.Extensions.DuplicatesExtension -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! From 30df5538251ae650466901ead2b24966289d4a04 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sat, 18 Nov 2023 12:32:28 -0500 Subject: [PATCH 41/51] checkout master file --- MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt index 057e63bee..ce7910980 100644 --- a/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -30,7 +30,6 @@ MoreLinq.Extensions.CountBetweenExtension MoreLinq.Extensions.CountByExtension MoreLinq.Extensions.CountDownExtension MoreLinq.Extensions.DistinctByExtension -MoreLinq.Extensions.DuplicatesExtension MoreLinq.Extensions.EndsWithExtension MoreLinq.Extensions.EquiZipExtension MoreLinq.Extensions.EvaluateExtension @@ -184,8 +183,6 @@ static MoreLinq.Extensions.CountByExtension.CountBy(this System.C static MoreLinq.Extensions.CountDownExtension.CountDown(this System.Collections.Generic.IEnumerable! source, int count, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DistinctByExtension.DistinctBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DistinctByExtension.DistinctBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.EndsWithExtension.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> bool static MoreLinq.Extensions.EndsWithExtension.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEqualityComparer? comparer) -> bool static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! @@ -444,8 +441,6 @@ static MoreLinq.MoreEnumerable.CountBy(this System.Collections.Ge static MoreLinq.MoreEnumerable.CountDown(this System.Collections.Generic.IEnumerable! source, int count, System.Func! resultSelector) -> 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.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> bool static MoreLinq.MoreEnumerable.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEqualityComparer? comparer) -> bool static MoreLinq.MoreEnumerable.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! From cafb9ba9f6f5c1f35fff7d9f3d5830f755ea3582 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sat, 18 Nov 2023 12:32:48 -0500 Subject: [PATCH 42/51] add unshipped items --- MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt index ce7910980..057e63bee 100644 --- a/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -30,6 +30,7 @@ MoreLinq.Extensions.CountBetweenExtension MoreLinq.Extensions.CountByExtension MoreLinq.Extensions.CountDownExtension MoreLinq.Extensions.DistinctByExtension +MoreLinq.Extensions.DuplicatesExtension MoreLinq.Extensions.EndsWithExtension MoreLinq.Extensions.EquiZipExtension MoreLinq.Extensions.EvaluateExtension @@ -183,6 +184,8 @@ static MoreLinq.Extensions.CountByExtension.CountBy(this System.C static MoreLinq.Extensions.CountDownExtension.CountDown(this System.Collections.Generic.IEnumerable! source, int count, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DistinctByExtension.DistinctBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.DistinctByExtension.DistinctBy(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.Extensions.DuplicatesExtension.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.EndsWithExtension.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> bool static MoreLinq.Extensions.EndsWithExtension.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEqualityComparer? comparer) -> bool static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! @@ -441,6 +444,8 @@ static MoreLinq.MoreEnumerable.CountBy(this System.Collections.Ge static MoreLinq.MoreEnumerable.CountDown(this System.Collections.Generic.IEnumerable! source, int count, System.Func! resultSelector) -> 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.Duplicates(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IEnumerable! +static MoreLinq.MoreEnumerable.Duplicates(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> bool static MoreLinq.MoreEnumerable.EndsWith(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEqualityComparer? comparer) -> bool static MoreLinq.MoreEnumerable.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! From 3350239bbae35d1c43a358dbe8fd4d3106f3c7eb Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sun, 19 Nov 2023 11:47:09 -0500 Subject: [PATCH 43/51] apply pr suggestions --- MoreLinq.Test/DuplicatesTest.cs | 86 ++++++++++++++++----------------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index 999fc29ac..1de9164be 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -39,88 +39,86 @@ static IEnumerable Source() throw new TestException(); } - using var source = TestingSequence.Of(Source()); + using var source = Source().AsTestingSequence(); - void Act() => source.Duplicates().Take(1); + var results = source.Duplicates().Take(1).ToArray(); - Assert.That(Act, Throws.Nothing); + Assert.That(results, Is.EqualTo(new[] { "DUPLICATED_STRING" })); } [Test] - public void When_Asking_For_Duplicates_On_Sequence_Without_Duplicates_Then_Empty_Sequence_Is_Returned() + public void Sequence_Without_Duplicates_Returns_Empty_Sequence() { - using var testingSequence = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); + using var input = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); - var duplicates = testingSequence.Duplicates(); + var results = input.Duplicates().ToArray(); - Assert.That(duplicates, Is.Empty); + Assert.That(results, Is.Empty); } [Test] - public void When_Asking_For_Duplicates_On_Sequence_With_Duplicates_Then_Duplicates_Are_Returned() + public void Sequence_With_Duplicates_Returns_Duplicates() { - using var testingSequence = TestingSequence.Of( - "FirstElement", - "DUPLICATED_STRING", - "DUPLICATED_STRING", - "DUPLICATED_STRING", - "ThirdElement" - ); - - var duplicates = testingSequence.Duplicates().ToArray(); - - Assert.That(duplicates, Contains.Item("DUPLICATED_STRING")); - Assert.That(duplicates.AtMost(1), Is.True); + using var input = + TestingSequence.Of("FirstElement", + "DUPLICATED_STRING", + "DUPLICATED_STRING", + "DUPLICATED_STRING", + "ThirdElement"); + + var results = input.Duplicates().ToArray(); + + Assert.That(results, Contains.Item("DUPLICATED_STRING")); + Assert.That(results, Has.Exactly(1).Items); } [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Multiple_Duplicates_Then_Duplicates_Are_Returned() { - using var testingSequence = TestingSequence.Of( - "FirstElement", - "DUPLICATED_STRING", - "DUPLICATED_STRING", - "DUPLICATED_STRING", - "ThirdElement", - "SECOND_DUPLICATED_STRING", - "SECOND_DUPLICATED_STRING" - ); - - var duplicates = testingSequence.Duplicates().ToArray(); - - Assert.That(duplicates, Contains.Item("DUPLICATED_STRING")); - Assert.That(duplicates, Contains.Item("SECOND_DUPLICATED_STRING")); - Assert.That(duplicates.AtMost(2), Is.True); + using var input = + TestingSequence.Of("FirstElement", + "DUPLICATED_STRING", + "DUPLICATED_STRING", + "DUPLICATED_STRING", + "ThirdElement", + "SECOND_DUPLICATED_STRING", + "SECOND_DUPLICATED_STRING"); + + var results = input.Duplicates().ToArray(); + + Assert.That(results, Contains.Item("DUPLICATED_STRING")); + Assert.That(results, Contains.Item("SECOND_DUPLICATED_STRING")); + Assert.That(results.AtMost(2), Is.True); } [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Comparer_Then_Duplicates_Are_Returned() { - using var testingSequence = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); + using var input = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); - var duplicates = testingSequence.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); + var results = input.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); - Assert.That(duplicates.AtMost(1), Is.True); + Assert.That(results.AtMost(1), Is.True); } [Test] public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_False_Comparer_Then_Empty_Sequence_Is_Returned() { - using var testingSequence = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); + using var input = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); - var duplicates = testingSequence.Duplicates(new DummyStringAlwaysFalseComparer()); + var results = input.Duplicates(new DummyStringAlwaysFalseComparer()).ToArray(); - Assert.That(duplicates, Is.Empty); + Assert.That(results, Is.Empty); } [Test] public void When_Asking_For_Duplicates_On_Multiple_Duplicates_Sequence_With_Custom_Always_False_Comparer_Then_Empty_Sequence_Is_Returned() { - using var testingSequence = TestingSequence.Of("DUPLICATED_STRING", "DUPLICATED_STRING", "DUPLICATED_STRING"); + using var input = TestingSequence.Of("DUPLICATED_STRING", "DUPLICATED_STRING", "DUPLICATED_STRING"); - var duplicates = testingSequence.Duplicates(new DummyStringAlwaysFalseComparer()); + var results = input.Duplicates(new DummyStringAlwaysFalseComparer()).ToArray(); - Assert.That(duplicates, Is.Empty); + Assert.That(results, Is.Empty); } sealed class DummyStringAlwaysTrueComparer : IEqualityComparer From c932a23ece0e5ded2de8cefe079f4563bbbf75a5 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sun, 19 Nov 2023 11:47:26 -0500 Subject: [PATCH 44/51] change assert type --- MoreLinq.Test/DuplicatesTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index 1de9164be..786c7f5e9 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -88,7 +88,7 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Multiple_Duplicates_Then Assert.That(results, Contains.Item("DUPLICATED_STRING")); Assert.That(results, Contains.Item("SECOND_DUPLICATED_STRING")); - Assert.That(results.AtMost(2), Is.True); + Assert.That(results, Has.Exactly(2).Items); } [Test] From 416bc598d5793b22664febdd95448ab86f44cd3a Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sun, 19 Nov 2023 11:47:55 -0500 Subject: [PATCH 45/51] change assert type --- MoreLinq.Test/DuplicatesTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index 786c7f5e9..ff442ba75 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -98,7 +98,7 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Compa var results = input.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); - Assert.That(results.AtMost(1), Is.True); + Assert.That(results, Has.Exactly(1).Items); } [Test] From 61b7da1aab74c3f4b3e5126cc3c967d4a48ac7c6 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sun, 19 Nov 2023 11:52:08 -0500 Subject: [PATCH 46/51] using delegate instead of custom class --- MoreLinq.Test/DuplicatesTest.cs | 45 ++++++--------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index ff442ba75..56ac4d6dd 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -18,6 +18,7 @@ namespace MoreLinq.Test { using System.Collections.Generic; + using Delegating; using NUnit.Framework; [TestFixture] @@ -73,7 +74,7 @@ public void Sequence_With_Duplicates_Returns_Duplicates() } [Test] - public void When_Asking_For_Duplicates_On_Sequence_With_Multiple_Duplicates_Then_Duplicates_Are_Returned() + public void Sequence_With_Multiple_Duplicates_Returns_One_Instance_Of_Each_Duplicates() { using var input = TestingSequence.Of("FirstElement", @@ -92,47 +93,17 @@ public void When_Asking_For_Duplicates_On_Sequence_With_Multiple_Duplicates_Then } [Test] - public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_True_Comparer_Then_Duplicates_Are_Returned() - { - using var input = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); - - var results = input.Duplicates(new DummyStringAlwaysTrueComparer()).ToArray(); - - Assert.That(results, Has.Exactly(1).Items); - } - - [Test] - public void When_Asking_For_Duplicates_On_Sequence_With_Custom_Always_False_Comparer_Then_Empty_Sequence_Is_Returned() - { - using var input = TestingSequence.Of("FirstElement", "SecondElement", "ThirdElement"); - - var results = input.Duplicates(new DummyStringAlwaysFalseComparer()).ToArray(); - - Assert.That(results, Is.Empty); - } - - [Test] - public void When_Asking_For_Duplicates_On_Multiple_Duplicates_Sequence_With_Custom_Always_False_Comparer_Then_Empty_Sequence_Is_Returned() + public void Sequence_With_Duplicates_But_Using_Comparer_That_Always_Return_False_Returns_Empty_Sequence() { using var input = TestingSequence.Of("DUPLICATED_STRING", "DUPLICATED_STRING", "DUPLICATED_STRING"); - var results = input.Duplicates(new DummyStringAlwaysFalseComparer()).ToArray(); +#pragma warning disable CA1307 // Specify StringComparison for clarity + var results = + input.Duplicates(Delegate.EqualityComparer((_, _) => false, + (string s) => s.GetHashCode())); +#pragma warning restore CA1307 // Specify StringComparison for clarity Assert.That(results, Is.Empty); } - - sealed class DummyStringAlwaysTrueComparer : IEqualityComparer - { - public bool Equals(string? x, string? y) => true; - - public int GetHashCode(string obj) => 0; - } - - sealed class DummyStringAlwaysFalseComparer : IEqualityComparer - { - public bool Equals(string? x, string? y) => false; - - public int GetHashCode(string obj) => 0; - } } } From 4c1d5dca293bc879b428c5479f772774940b4a63 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sun, 19 Nov 2023 11:52:41 -0500 Subject: [PATCH 47/51] update doc --- MoreLinq/Duplicates.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index 0aed90597..e26666d6d 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -28,7 +28,7 @@ static partial class MoreEnumerable /// /// The source sequence. /// The type of the elements in the source sequence. - /// is null. + /// is . /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. @@ -45,7 +45,7 @@ public static IEnumerable Duplicates(this IEnumerable /// equals another. If , the default equality comparer for /// is used. /// The type of the elements in the source sequence. - /// is null. + /// is . /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. From 7deb08568667fbf5a89869e2f25e24f9e9c19151 Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sun, 19 Nov 2023 11:53:00 -0500 Subject: [PATCH 48/51] regen extensions --- MoreLinq/Extensions.g.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index db8e5f7f4..83b2e90ac 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1293,7 +1293,7 @@ public static partial class DuplicatesExtension /// /// The source sequence. /// The type of the elements in the source sequence. - /// is null. + /// is . /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. @@ -1309,7 +1309,7 @@ public static partial class DuplicatesExtension /// equals another. If , the default equality comparer for /// is used. /// The type of the elements in the source sequence. - /// is null. + /// is . /// All elements that are duplicated. /// This operator uses deferred execution and streams its results. From 8fd8d85e28ce4485808619f85d6e8267267fb18c Mon Sep 17 00:00:00 2001 From: Julien Aspirot Date: Sun, 19 Nov 2023 11:54:49 -0500 Subject: [PATCH 49/51] Update MoreLinq/Duplicates.cs fix formatting Co-authored-by: Atif Aziz --- MoreLinq/Duplicates.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MoreLinq/Duplicates.cs b/MoreLinq/Duplicates.cs index e26666d6d..b29f9a65d 100644 --- a/MoreLinq/Duplicates.cs +++ b/MoreLinq/Duplicates.cs @@ -54,11 +54,11 @@ public static IEnumerable Duplicates(this IEnumerable if (source is null) throw new ArgumentNullException(nameof(source)); return from e in source.ScanBy(static e => e, - static _ => 0, - static (count, _, _) => unchecked(Math.Min(count + 1, 3)), - comparer) - where e.Value is 2 - select e.Key; + static _ => 0, + static (count, _, _) => unchecked(Math.Min(count + 1, 3)), + comparer) + where e.Value is 2 + select e.Key; } } } From ce6b842e13670976dff4afe3731f99f262c761ee Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sun, 19 Nov 2023 18:15:47 +0100 Subject: [PATCH 50/51] Fix formatting --- MoreLinq.Test/DuplicatesTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index 56ac4d6dd..391cab3d0 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -97,10 +97,10 @@ public void Sequence_With_Duplicates_But_Using_Comparer_That_Always_Return_False { using var input = TestingSequence.Of("DUPLICATED_STRING", "DUPLICATED_STRING", "DUPLICATED_STRING"); -#pragma warning disable CA1307 // Specify StringComparison for clarity var results = input.Duplicates(Delegate.EqualityComparer((_, _) => false, - (string s) => s.GetHashCode())); +#pragma warning disable CA1307 // Specify StringComparison for clarity + (string s) => s.GetHashCode())); #pragma warning restore CA1307 // Specify StringComparison for clarity Assert.That(results, Is.Empty); From 5095c6fe6b5a9547a9a295f5dbe05a9721dbe907 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sun, 19 Nov 2023 18:19:13 +0100 Subject: [PATCH 51/51] Simplify comparer for the test --- MoreLinq.Test/DuplicatesTest.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/MoreLinq.Test/DuplicatesTest.cs b/MoreLinq.Test/DuplicatesTest.cs index 391cab3d0..2b97f471e 100644 --- a/MoreLinq.Test/DuplicatesTest.cs +++ b/MoreLinq.Test/DuplicatesTest.cs @@ -18,8 +18,8 @@ namespace MoreLinq.Test { using System.Collections.Generic; - using Delegating; using NUnit.Framework; + using Delegate = Delegating.Delegate; [TestFixture] public class DuplicatesTest @@ -97,11 +97,7 @@ public void Sequence_With_Duplicates_But_Using_Comparer_That_Always_Return_False { using var input = TestingSequence.Of("DUPLICATED_STRING", "DUPLICATED_STRING", "DUPLICATED_STRING"); - var results = - input.Duplicates(Delegate.EqualityComparer((_, _) => false, -#pragma warning disable CA1307 // Specify StringComparison for clarity - (string s) => s.GetHashCode())); -#pragma warning restore CA1307 // Specify StringComparison for clarity + var results = input.Duplicates(Delegate.EqualityComparer((_, _) => false, (string _) => 0)); Assert.That(results, Is.Empty); }