Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Hide extensions that conflict with newer .NET versions #945

Merged
merged 17 commits into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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

#if !NET471_OR_GREATER && !NETSTANDARD1_6_OR_GREATER && !NETCOREAPP2_0_OR_GREATER

namespace MoreLinq.Test
{
using System.Collections.Generic;
Expand Down Expand Up @@ -90,3 +92,5 @@ public void AppendWithSharedSource()
}
}
}

#endif
4 changes: 4 additions & 0 deletions MoreLinq.Test/DistinctByTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// limitations under the License.
#endregion

#if !NET6_0_OR_GREATER

namespace MoreLinq.Test
{
using System;
Expand Down Expand Up @@ -61,3 +63,5 @@ public void DistinctByIsLazyWithComparer()
}
}
}

#endif
5 changes: 5 additions & 0 deletions MoreLinq.Test/Enumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public static bool Any<TSource>(this IEnumerable<TSource> source) =>
public static bool Any<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) =>
LinqEnumerable.Any(source, predicate);

#if NET471_OR_GREATER || NET6_0_OR_GREATER
public static IEnumerable<TSource> Append<TSource> (this IEnumerable<TSource> source, TSource element) =>
LinqEnumerable.Append(source, element);
#endif

public static IEnumerable<TSource> AsEnumerable<TSource>(this IEnumerable<TSource> source) =>
LinqEnumerable.AsEnumerable(source);

Expand Down
4 changes: 4 additions & 0 deletions MoreLinq.Test/PrependTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// limitations under the License.
#endregion

#if !NET471_OR_GREATER && !NETSTANDARD1_6_OR_GREATER && !NETCOREAPP2_0_OR_GREATER

namespace MoreLinq.Test
{
using System.Collections.Generic;
Expand Down Expand Up @@ -89,3 +91,5 @@ public void PrependWithSharedSource()
}
}
}

#endif
4 changes: 4 additions & 0 deletions MoreLinq.Test/SkipLastTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// limitations under the License.
#endregion

#if !NETSTANDARD2_1 && !NETCOREAPP2_0_OR_GREATER

namespace MoreLinq.Test
{
using System.Collections.Generic;
Expand Down Expand Up @@ -68,3 +70,5 @@ public void SkipLastUsesCollectionCountAtIterationTime()
}
}
}

#endif
4 changes: 4 additions & 0 deletions MoreLinq.Test/TakeLastTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// limitations under the License.
#endregion

#if !NETSTANDARD2_1 && !NETCOREAPP2_0_OR_GREATER

namespace MoreLinq.Test
{
using NUnit.Framework;
Expand Down Expand Up @@ -89,3 +91,5 @@ static void AssertTakeLast<T>(ICollection<T> input, int count, Action<IEnumerabl
}
}
}

#endif
4 changes: 4 additions & 0 deletions MoreLinq/Append.cs
atifaziz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ static partial class MoreEnumerable
/// <returns>A sequence consisting of the head elements and the given tail element.</returns>
/// <remarks>This operator uses deferred execution and streams its results.</remarks>

#if NET471_OR_GREATER || NETSTANDARD1_6_OR_GREATER || NETCOREAPP2_0_OR_GREATER
public static IEnumerable<T> Append<T>(IEnumerable<T> head, T tail)
#else
public static IEnumerable<T> Append<T>(this IEnumerable<T> head, T tail)
#endif
{
if (head == null) throw new ArgumentNullException(nameof(head));
return head is PendNode<T> node
Expand Down
112 changes: 112 additions & 0 deletions MoreLinq/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:MoreLinq.Extensions.AppendExtension</Target>
<Left>lib/net462/MoreLinq.dll</Left>
<Right>lib/netstandard2.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:MoreLinq.Extensions.PrependExtension</Target>
<Left>lib/net462/MoreLinq.dll</Left>
<Right>lib/netstandard2.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:MoreLinq.Extensions.AppendExtension</Target>
<Left>lib/net6.0/MoreLinq.dll</Left>
<Right>lib/net6.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:MoreLinq.Extensions.PrependExtension</Target>
<Left>lib/net6.0/MoreLinq.dll</Left>
<Right>lib/net6.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:MoreLinq.Extensions.AppendExtension</Target>
<Left>lib/netstandard2.0/MoreLinq.dll</Left>
<Right>lib/netstandard2.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:MoreLinq.Extensions.PrependExtension</Target>
<Left>lib/netstandard2.0/MoreLinq.dll</Left>
<Right>lib/netstandard2.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:MoreLinq.Extensions.AppendExtension</Target>
<Left>lib/netstandard2.1/MoreLinq.dll</Left>
<Right>lib/netstandard2.1/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:MoreLinq.Extensions.PrependExtension</Target>
<Left>lib/netstandard2.1/MoreLinq.dll</Left>
<Right>lib/netstandard2.1/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Append``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/net462/MoreLinq.dll</Left>
<Right>lib/netstandard2.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/net462/MoreLinq.dll</Left>
<Right>lib/netstandard2.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Prepend``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/net462/MoreLinq.dll</Left>
<Right>lib/netstandard2.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Append``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/net6.0/MoreLinq.dll</Left>
<Right>lib/net6.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/net6.0/MoreLinq.dll</Left>
<Right>lib/net6.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Prepend``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/net6.0/MoreLinq.dll</Left>
<Right>lib/net6.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Append``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/netstandard2.0/MoreLinq.dll</Left>
<Right>lib/netstandard2.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/netstandard2.0/MoreLinq.dll</Left>
<Right>lib/netstandard2.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Prepend``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/netstandard2.0/MoreLinq.dll</Left>
<Right>lib/netstandard2.0/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Append``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/netstandard2.1/MoreLinq.dll</Left>
<Right>lib/netstandard2.1/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/netstandard2.1/MoreLinq.dll</Left>
<Right>lib/netstandard2.1/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:MoreLinq.MoreEnumerable.Prepend``1(System.Collections.Generic.IEnumerable{``0},``0)</Target>
<Left>lib/netstandard2.1/MoreLinq.dll</Left>
<Right>lib/netstandard2.1/MoreLinq.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>PKV006</DiagnosticId>
<Target>.NETStandard,Version=v1.0</Target>
Expand Down
12 changes: 11 additions & 1 deletion MoreLinq/DistinctBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ static partial class MoreEnumerable
/// <returns>A sequence consisting of distinct elements from the source sequence,
/// comparing them by the specified key projection.</returns>

#if NET6_0_OR_GREATER
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(IEnumerable<TSource> source,
Func<TSource, TKey> keySelector)
#else
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source,
Func<TSource, TKey> keySelector)
#endif
{
return source.DistinctBy(keySelector, null);
return DistinctBy(source, keySelector, null);
}

/// <summary>
Expand All @@ -62,8 +67,13 @@ public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TS
/// <returns>A sequence consisting of distinct elements from the source sequence,
/// comparing them by the specified key projection.</returns>

#if NET6_0_OR_GREATER
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(IEnumerable<TSource> source,
Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? comparer)
#else
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source,
Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? comparer)
#endif
{
if (source == null) throw new ArgumentNullException(nameof(source));
if (keySelector == null) throw new ArgumentNullException(nameof(keySelector));
Expand Down
4 changes: 4 additions & 0 deletions MoreLinq/Prepend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ static partial class MoreEnumerable
/// The <c>result</c> variable, when iterated over, will yield
/// 0, 1, 2 and 3, in turn.

#if NET471_OR_GREATER || NETSTANDARD1_6_OR_GREATER || NETCOREAPP2_0_OR_GREATER
public static IEnumerable<TSource> Prepend<TSource>(IEnumerable<TSource> source, TSource value)
#else
public static IEnumerable<TSource> Prepend<TSource>(this IEnumerable<TSource> source, TSource value)
#endif
{
if (source == null) throw new ArgumentNullException(nameof(source));
return source is PendNode<TSource> node
Expand Down
16 changes: 16 additions & 0 deletions MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
#nullable enable
*REMOVED*static MoreLinq.MoreEnumerable.Append<T>(this System.Collections.Generic.IEnumerable<T>! head, T tail) -> System.Collections.Generic.IEnumerable<T>!
*REMOVED*static MoreLinq.MoreEnumerable.Concat<T>(this System.Collections.Generic.IEnumerable<T>! head, T tail) -> System.Collections.Generic.IEnumerable<T>!
*REMOVED*static MoreLinq.MoreEnumerable.Prepend<TSource>(this System.Collections.Generic.IEnumerable<TSource>! source, TSource value) -> System.Collections.Generic.IEnumerable<TSource>!
*REMOVED*static MoreLinq.MoreEnumerable.DistinctBy<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector) -> System.Collections.Generic.IEnumerable<TSource>!
*REMOVED*static MoreLinq.MoreEnumerable.DistinctBy<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer) -> System.Collections.Generic.IEnumerable<TSource>!
*REMOVED*static MoreLinq.MoreEnumerable.SkipLast<T>(this System.Collections.Generic.IEnumerable<T>! source, int count) -> System.Collections.Generic.IEnumerable<T>!
*REMOVED*static MoreLinq.MoreEnumerable.TakeLast<TSource>(this System.Collections.Generic.IEnumerable<TSource>! source, int count) -> System.Collections.Generic.IEnumerable<TSource>!
*REMOVED*static MoreLinq.MoreEnumerable.ToHashSet<TSource>(this System.Collections.Generic.IEnumerable<TSource>! source) -> System.Collections.Generic.HashSet<TSource>!
*REMOVED*static MoreLinq.MoreEnumerable.ToHashSet<TSource>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Collections.Generic.IEqualityComparer<TSource>? comparer) -> System.Collections.Generic.HashSet<TSource>!
static MoreLinq.MoreEnumerable.Append<T>(System.Collections.Generic.IEnumerable<T>! head, T tail) -> System.Collections.Generic.IEnumerable<T>!
static MoreLinq.MoreEnumerable.DistinctBy<TSource, TKey>(System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector) -> System.Collections.Generic.IEnumerable<TSource>!
static MoreLinq.MoreEnumerable.DistinctBy<TSource, TKey>(System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer) -> System.Collections.Generic.IEnumerable<TSource>!
static MoreLinq.MoreEnumerable.Prepend<TSource>(System.Collections.Generic.IEnumerable<TSource>! source, TSource value) -> System.Collections.Generic.IEnumerable<TSource>!
static MoreLinq.MoreEnumerable.SkipLast<T>(System.Collections.Generic.IEnumerable<T>! source, int count) -> System.Collections.Generic.IEnumerable<T>!
static MoreLinq.MoreEnumerable.TakeLast<TSource>(System.Collections.Generic.IEnumerable<TSource>! source, int count) -> System.Collections.Generic.IEnumerable<TSource>!
static MoreLinq.MoreEnumerable.ToHashSet<TSource>(System.Collections.Generic.IEnumerable<TSource>! source) -> System.Collections.Generic.HashSet<TSource>!
static MoreLinq.MoreEnumerable.ToHashSet<TSource>(System.Collections.Generic.IEnumerable<TSource>! source, System.Collections.Generic.IEqualityComparer<TSource>? comparer) -> System.Collections.Generic.HashSet<TSource>!
4 changes: 4 additions & 0 deletions MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#nullable enable
*REMOVED*static MoreLinq.MoreEnumerable.Append<T>(this System.Collections.Generic.IEnumerable<T>! head, T tail) -> System.Collections.Generic.IEnumerable<T>!
*REMOVED*static MoreLinq.MoreEnumerable.Concat<T>(this System.Collections.Generic.IEnumerable<T>! head, T tail) -> System.Collections.Generic.IEnumerable<T>!
*REMOVED*static MoreLinq.MoreEnumerable.Prepend<TSource>(this System.Collections.Generic.IEnumerable<TSource>! source, TSource value) -> System.Collections.Generic.IEnumerable<TSource>!
static MoreLinq.MoreEnumerable.Append<T>(System.Collections.Generic.IEnumerable<T>! head, T tail) -> System.Collections.Generic.IEnumerable<T>!
static MoreLinq.MoreEnumerable.Prepend<TSource>(System.Collections.Generic.IEnumerable<TSource>! source, TSource value) -> System.Collections.Generic.IEnumerable<TSource>!
12 changes: 12 additions & 0 deletions MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
#nullable enable
*REMOVED*static MoreLinq.MoreEnumerable.Append<T>(this System.Collections.Generic.IEnumerable<T>! head, T tail) -> System.Collections.Generic.IEnumerable<T>!
*REMOVED*static MoreLinq.MoreEnumerable.Concat<T>(this System.Collections.Generic.IEnumerable<T>! head, T tail) -> System.Collections.Generic.IEnumerable<T>!
*REMOVED*static MoreLinq.MoreEnumerable.Prepend<TSource>(this System.Collections.Generic.IEnumerable<TSource>! source, TSource value) -> System.Collections.Generic.IEnumerable<TSource>!
*REMOVED*static MoreLinq.MoreEnumerable.SkipLast<T>(this System.Collections.Generic.IEnumerable<T>! source, int count) -> System.Collections.Generic.IEnumerable<T>!
*REMOVED*static MoreLinq.MoreEnumerable.TakeLast<TSource>(this System.Collections.Generic.IEnumerable<TSource>! source, int count) -> System.Collections.Generic.IEnumerable<TSource>!
*REMOVED*static MoreLinq.MoreEnumerable.ToHashSet<TSource>(this System.Collections.Generic.IEnumerable<TSource>! source) -> System.Collections.Generic.HashSet<TSource>!
*REMOVED*static MoreLinq.MoreEnumerable.ToHashSet<TSource>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Collections.Generic.IEqualityComparer<TSource>? comparer) -> System.Collections.Generic.HashSet<TSource>!
static MoreLinq.MoreEnumerable.Append<T>(System.Collections.Generic.IEnumerable<T>! head, T tail) -> System.Collections.Generic.IEnumerable<T>!
static MoreLinq.MoreEnumerable.Prepend<TSource>(System.Collections.Generic.IEnumerable<TSource>! source, TSource value) -> System.Collections.Generic.IEnumerable<TSource>!
static MoreLinq.MoreEnumerable.SkipLast<T>(System.Collections.Generic.IEnumerable<T>! source, int count) -> System.Collections.Generic.IEnumerable<T>!
static MoreLinq.MoreEnumerable.TakeLast<TSource>(System.Collections.Generic.IEnumerable<TSource>! source, int count) -> System.Collections.Generic.IEnumerable<TSource>!
static MoreLinq.MoreEnumerable.ToHashSet<TSource>(System.Collections.Generic.IEnumerable<TSource>! source) -> System.Collections.Generic.HashSet<TSource>!
static MoreLinq.MoreEnumerable.ToHashSet<TSource>(System.Collections.Generic.IEnumerable<TSource>! source, System.Collections.Generic.IEqualityComparer<TSource>? comparer) -> System.Collections.Generic.HashSet<TSource>!
4 changes: 4 additions & 0 deletions MoreLinq/SkipLast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ static partial class MoreEnumerable
/// An <see cref="IEnumerable{T}"/> containing the source sequence elements except for the bypassed ones at the end.
/// </returns>

#if NETSTANDARD2_1 || NETCOREAPP2_0_OR_GREATER
public static IEnumerable<T> SkipLast<T>(IEnumerable<T> source, int count)
#else
public static IEnumerable<T> SkipLast<T>(this IEnumerable<T> source, int count)
#endif
{
if (source == null) throw new ArgumentNullException(nameof(source));

Expand Down
4 changes: 4 additions & 0 deletions MoreLinq/TakeLast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ static partial class MoreEnumerable
/// 56 and 78 in turn.
/// </example>

#if NETSTANDARD2_1 || NETCOREAPP2_0_OR_GREATER
public static IEnumerable<TSource> TakeLast<TSource>(IEnumerable<TSource> source, int count)
#else
public static IEnumerable<TSource> TakeLast<TSource>(this IEnumerable<TSource> source, int count)
#endif
{
if (source == null) throw new ArgumentNullException(nameof(source));

Expand Down
10 changes: 9 additions & 1 deletion MoreLinq/ToHashSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ static partial class MoreEnumerable
/// This evaluates the input sequence completely.
/// </remarks>

#if NETSTANDARD2_1 || NET472_OR_GREATER || NETCOREAPP2_0_OR_GREATER
public static HashSet<TSource> ToHashSet<TSource>(IEnumerable<TSource> source)
#else
public static HashSet<TSource> ToHashSet<TSource>(this IEnumerable<TSource> source)
#endif
{
return source.ToHashSet(null);
return ToHashSet(source, null);
}

/// <summary>
Expand All @@ -53,7 +57,11 @@ public static HashSet<TSource> ToHashSet<TSource>(this IEnumerable<TSource> sour
/// This evaluates the input sequence completely.
/// </remarks>

#if NETSTANDARD2_1 || NET472_OR_GREATER || NETCOREAPP2_0_OR_GREATER
public static HashSet<TSource> ToHashSet<TSource>(IEnumerable<TSource> source, IEqualityComparer<TSource>? comparer)
#else
public static HashSet<TSource> ToHashSet<TSource>(this IEnumerable<TSource> source, IEqualityComparer<TSource>? comparer)
#endif
{
if (source == null) throw new ArgumentNullException(nameof(source));
return new HashSet<TSource>(source, comparer);
Expand Down
Loading