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

Support .NET Standard 2.0 #672

Merged
merged 11 commits into from
Jul 17, 2024
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
<PackageVersion Include="DocFx.App" Version="2.77.0" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
Expand All @@ -17,6 +18,7 @@
<PackageVersion Include="MinVer" Version="5.0.0" />
<PackageVersion Include="Scriban" Version="5.10.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="ThisAssembly.Resources" Version="1.4.3" />
<PackageVersion Include="xunit" Version="2.9.0" />
</ItemGroup>
Expand All @@ -31,7 +33,6 @@

<ItemGroup>
<GlobalPackageReference Include="Meziantou.Analyzer" Version="2.0.160" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers" Version="3.3.1" />
<GlobalPackageReference Include="PolySharp" Version="1.14.1" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions Source/SuperLinq.Async/ElementAt.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if !NO_INDEX

namespace SuperLinq.Async;

public static partial class AsyncSuperEnumerable
Expand Down Expand Up @@ -101,3 +103,5 @@ CancellationToken cancellationToken
return (false, default);
}
}

#endif
4 changes: 4 additions & 0 deletions Source/SuperLinq.Async/FindIndex.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if !NO_INDEX

namespace SuperLinq.Async;

public static partial class AsyncSuperEnumerable
Expand Down Expand Up @@ -202,3 +204,5 @@ CancellationToken cancellationToken
}
}
}

#endif
4 changes: 4 additions & 0 deletions Source/SuperLinq.Async/FindLastIndex.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if !NO_INDEX

namespace SuperLinq.Async;

public static partial class AsyncSuperEnumerable
Expand Down Expand Up @@ -187,3 +189,5 @@ CancellationToken cancellationToken
}
}
}

#endif
6 changes: 3 additions & 3 deletions Source/SuperLinq.Async/GetShortestPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ public partial class AsyncSuperEnumerable
var queue = new UpdatablePriorityQueue<TState, (TState? parent, TCost? cost)>(
16,
priorityComparer: Comparer<(TState? parent, TCost? cost)>.Create(
(x, y) => costComparer.Compare(x.cost, y.cost)),
(x, y) => costComparer.Compare(x.cost!, y.cost!)),
stateComparer);

var current = start;
Expand Down Expand Up @@ -1154,7 +1154,7 @@ public partial class AsyncSuperEnumerable
cancellationToken.ThrowIfCancellationRequested();

if (!totalCost.TryGetValue(current, out var oldCost)
|| costComparer.Compare(costs.traversed, oldCost) < 0)
|| costComparer.Compare(costs.traversed!, oldCost!) < 0)
{
totalCost[current] = costs.traversed;
if (await predicate(current).ConfigureAwait(false))
Expand Down Expand Up @@ -1503,7 +1503,7 @@ public partial class AsyncSuperEnumerable
cancellationToken.ThrowIfCancellationRequested();

if (!totalCost.TryGetValue(current, out var oldCost)
|| costComparer.Compare(from.traversed, oldCost.traversed) < 0)
|| costComparer.Compare(from.traversed!, oldCost.traversed!) < 0)
{
totalCost[current] = (from.parent, from.traversed);
if (await predicate(current).ConfigureAwait(false))
Expand Down
4 changes: 3 additions & 1 deletion Source/SuperLinq.Async/IAsyncBuffer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SuperLinq.Async;
namespace SuperLinq.Async;

/// <summary>
/// Represents a cached sequence that can be re-enumerated multiple times.
Expand All @@ -20,6 +20,7 @@ public interface IAsyncBuffer<out T> : IAsyncEnumerable<T>, IAsyncDisposable
/// </summary>
int Count { get; }

#if NETCOREAPP
/// <summary>
/// Configures how awaits on the tasks returned from an async disposable are performed.
/// </summary>
Expand All @@ -31,4 +32,5 @@ public interface IAsyncBuffer<out T> : IAsyncEnumerable<T>, IAsyncDisposable
/// </returns>
public ConfiguredAsyncDisposable ConfigureAwait(bool continueOnCapturedContext) =>
((IAsyncDisposable)this).ConfigureAwait(continueOnCapturedContext);
#endif
}
4 changes: 4 additions & 0 deletions Source/SuperLinq.Async/IndexOf.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if !NO_INDEX

namespace SuperLinq.Async;

public static partial class AsyncSuperEnumerable
Expand Down Expand Up @@ -126,3 +128,5 @@ public static ValueTask<int> IndexOf<TSource>(
return FindIndex(source, i => EqualityComparer<TSource>.Default.Equals(i, item), index, count, cancellationToken);
}
}

#endif
4 changes: 4 additions & 0 deletions Source/SuperLinq.Async/Insert.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if !NO_INDEX

namespace SuperLinq.Async;

public static partial class AsyncSuperEnumerable
Expand Down Expand Up @@ -136,3 +138,5 @@ static async IAsyncEnumerable<T> Core(
}
}
}

#endif
6 changes: 5 additions & 1 deletion Source/SuperLinq.Async/Join.MergeJoin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,10 @@ file sealed class ComparerEqualityComparer<TKey>(
IComparer<TKey> comparer
) : IEqualityComparer<TKey>
{
public bool Equals([AllowNull] TKey x, [AllowNull] TKey y) => comparer.Compare(x, y) == 0;
public bool Equals([AllowNull] TKey x, [AllowNull] TKey y) => comparer.Compare(x!, y!) == 0;
#if NETCOREAPP
public int GetHashCode([DisallowNull] TKey obj) => ThrowHelper.ThrowNotSupportedException<int>();
#else
public int GetHashCode(TKey obj) => ThrowHelper.ThrowNotSupportedException<int>();
#endif
}
4 changes: 4 additions & 0 deletions Source/SuperLinq.Async/LastIndexOf.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if !NO_INDEX

namespace SuperLinq.Async;

public static partial class AsyncSuperEnumerable
Expand Down Expand Up @@ -135,3 +137,5 @@ public static ValueTask<int> LastIndexOf<TSource>(
);
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Loading