Skip to content

Commit 0bbcff5

Browse files
Support .NET Standard 2.0 (#672)
* Support .NET Standard 2.0 * Hide API using Index/Range The polyfills generated by PolySharp cannot be made public as there will be conflicts with the polyfills generated by others. * Use HashCode from Microsoft.Bcl.HashCode --------- Co-authored-by: Stuart Turner <[email protected]>
1 parent 4d7b91a commit 0bbcff5

File tree

103 files changed

+1528
-322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1528
-322
lines changed

Directory.Packages.props

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
1010
<PackageVersion Include="DocFx.App" Version="2.77.0" />
1111
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
12+
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
1213
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
1314
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
1415
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
@@ -17,6 +18,7 @@
1718
<PackageVersion Include="MinVer" Version="5.0.0" />
1819
<PackageVersion Include="Scriban" Version="5.10.0" />
1920
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
21+
<PackageVersion Include="System.Memory" Version="4.5.5" />
2022
<PackageVersion Include="ThisAssembly.Resources" Version="1.4.3" />
2123
<PackageVersion Include="xunit" Version="2.9.0" />
2224
</ItemGroup>
@@ -31,7 +33,6 @@
3133

3234
<ItemGroup>
3335
<GlobalPackageReference Include="Meziantou.Analyzer" Version="2.0.160" />
34-
<GlobalPackageReference Include="Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers" Version="3.3.1" />
3536
<GlobalPackageReference Include="PolySharp" Version="1.14.1" />
3637
</ItemGroup>
3738
</Project>

Source/SuperLinq.Async/ElementAt.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
#if !NO_INDEX
5+
46
namespace SuperLinq.Async;
57

68
public static partial class AsyncSuperEnumerable
@@ -101,3 +103,5 @@ CancellationToken cancellationToken
101103
return (false, default);
102104
}
103105
}
106+
107+
#endif

Source/SuperLinq.Async/FindIndex.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_INDEX
2+
13
namespace SuperLinq.Async;
24

35
public static partial class AsyncSuperEnumerable
@@ -202,3 +204,5 @@ CancellationToken cancellationToken
202204
}
203205
}
204206
}
207+
208+
#endif

Source/SuperLinq.Async/FindLastIndex.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_INDEX
2+
13
namespace SuperLinq.Async;
24

35
public static partial class AsyncSuperEnumerable
@@ -187,3 +189,5 @@ CancellationToken cancellationToken
187189
}
188190
}
189191
}
192+
193+
#endif

Source/SuperLinq.Async/GetShortestPath.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ public partial class AsyncSuperEnumerable
812812
var queue = new UpdatablePriorityQueue<TState, (TState? parent, TCost? cost)>(
813813
16,
814814
priorityComparer: Comparer<(TState? parent, TCost? cost)>.Create(
815-
(x, y) => costComparer.Compare(x.cost, y.cost)),
815+
(x, y) => costComparer.Compare(x.cost!, y.cost!)),
816816
stateComparer);
817817

818818
var current = start;
@@ -1154,7 +1154,7 @@ public partial class AsyncSuperEnumerable
11541154
cancellationToken.ThrowIfCancellationRequested();
11551155

11561156
if (!totalCost.TryGetValue(current, out var oldCost)
1157-
|| costComparer.Compare(costs.traversed, oldCost) < 0)
1157+
|| costComparer.Compare(costs.traversed!, oldCost!) < 0)
11581158
{
11591159
totalCost[current] = costs.traversed;
11601160
if (await predicate(current).ConfigureAwait(false))
@@ -1503,7 +1503,7 @@ public partial class AsyncSuperEnumerable
15031503
cancellationToken.ThrowIfCancellationRequested();
15041504

15051505
if (!totalCost.TryGetValue(current, out var oldCost)
1506-
|| costComparer.Compare(from.traversed, oldCost.traversed) < 0)
1506+
|| costComparer.Compare(from.traversed!, oldCost.traversed!) < 0)
15071507
{
15081508
totalCost[current] = (from.parent, from.traversed);
15091509
if (await predicate(current).ConfigureAwait(false))

Source/SuperLinq.Async/IAsyncBuffer.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace SuperLinq.Async;
1+
namespace SuperLinq.Async;
22

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

23+
#if NETCOREAPP
2324
/// <summary>
2425
/// Configures how awaits on the tasks returned from an async disposable are performed.
2526
/// </summary>
@@ -31,4 +32,5 @@ public interface IAsyncBuffer<out T> : IAsyncEnumerable<T>, IAsyncDisposable
3132
/// </returns>
3233
public ConfiguredAsyncDisposable ConfigureAwait(bool continueOnCapturedContext) =>
3334
((IAsyncDisposable)this).ConfigureAwait(continueOnCapturedContext);
35+
#endif
3436
}

Source/SuperLinq.Async/IndexOf.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_INDEX
2+
13
namespace SuperLinq.Async;
24

35
public static partial class AsyncSuperEnumerable
@@ -126,3 +128,5 @@ public static ValueTask<int> IndexOf<TSource>(
126128
return FindIndex(source, i => EqualityComparer<TSource>.Default.Equals(i, item), index, count, cancellationToken);
127129
}
128130
}
131+
132+
#endif

Source/SuperLinq.Async/Insert.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_INDEX
2+
13
namespace SuperLinq.Async;
24

35
public static partial class AsyncSuperEnumerable
@@ -136,3 +138,5 @@ static async IAsyncEnumerable<T> Core(
136138
}
137139
}
138140
}
141+
142+
#endif

Source/SuperLinq.Async/Join.MergeJoin.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,10 @@ file sealed class ComparerEqualityComparer<TKey>(
722722
IComparer<TKey> comparer
723723
) : IEqualityComparer<TKey>
724724
{
725-
public bool Equals([AllowNull] TKey x, [AllowNull] TKey y) => comparer.Compare(x, y) == 0;
725+
public bool Equals([AllowNull] TKey x, [AllowNull] TKey y) => comparer.Compare(x!, y!) == 0;
726+
#if NETCOREAPP
726727
public int GetHashCode([DisallowNull] TKey obj) => ThrowHelper.ThrowNotSupportedException<int>();
728+
#else
729+
public int GetHashCode(TKey obj) => ThrowHelper.ThrowNotSupportedException<int>();
730+
#endif
727731
}

Source/SuperLinq.Async/LastIndexOf.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_INDEX
2+
13
namespace SuperLinq.Async;
24

35
public static partial class AsyncSuperEnumerable
@@ -135,3 +137,5 @@ public static ValueTask<int> LastIndexOf<TSource>(
135137
);
136138
}
137139
}
140+
141+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#nullable enable

0 commit comments

Comments
 (0)