Skip to content

Commit e273782

Browse files
Remove Invalid Share overload (#556)
1 parent 0c8f310 commit e273782

File tree

12 files changed

+8
-89
lines changed

12 files changed

+8
-89
lines changed

Source/SuperLinq.Async/PublicAPI/net6.0/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ static SuperLinq.Async.AsyncSuperEnumerable.Partition<T>(this System.Collections
66
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Partition<T, TResult>(this System.Collections.Generic.IAsyncEnumerable<T>! source, System.Func<T, bool>! predicate, System.Func<System.Collections.Generic.IAsyncEnumerable<T>!, System.Collections.Generic.IAsyncEnumerable<T>!, TResult>! resultSelector, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<TResult>
77
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Partition<T>(this System.Collections.Generic.IAsyncEnumerable<T>! source, System.Func<T, bool>! predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<(System.Collections.Generic.IAsyncEnumerable<T>! True, System.Collections.Generic.IAsyncEnumerable<T>! False)>
88
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Publish<TSource, TResult>(this System.Collections.Generic.IAsyncEnumerable<TSource>! source, System.Func<System.Collections.Generic.IAsyncEnumerable<TSource>!, System.Collections.Generic.IAsyncEnumerable<TResult>!>! selector) -> System.Collections.Generic.IAsyncEnumerable<TResult>!
9+
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Share<TSource, TResult>(this System.Collections.Generic.IAsyncEnumerable<TSource>! source, System.Func<System.Collections.Generic.IAsyncEnumerable<TSource>!, System.Collections.Generic.IAsyncEnumerable<TResult>!>! selector) -> System.Collections.Generic.IAsyncEnumerable<TResult>!

Source/SuperLinq.Async/PublicAPI/net7.0/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ static SuperLinq.Async.AsyncSuperEnumerable.Partition<T>(this System.Collections
66
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Partition<T, TResult>(this System.Collections.Generic.IAsyncEnumerable<T>! source, System.Func<T, bool>! predicate, System.Func<System.Collections.Generic.IAsyncEnumerable<T>!, System.Collections.Generic.IAsyncEnumerable<T>!, TResult>! resultSelector, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<TResult>
77
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Partition<T>(this System.Collections.Generic.IAsyncEnumerable<T>! source, System.Func<T, bool>! predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<(System.Collections.Generic.IAsyncEnumerable<T>! True, System.Collections.Generic.IAsyncEnumerable<T>! False)>
88
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Publish<TSource, TResult>(this System.Collections.Generic.IAsyncEnumerable<TSource>! source, System.Func<System.Collections.Generic.IAsyncEnumerable<TSource>!, System.Collections.Generic.IAsyncEnumerable<TResult>!>! selector) -> System.Collections.Generic.IAsyncEnumerable<TResult>!
9+
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Share<TSource, TResult>(this System.Collections.Generic.IAsyncEnumerable<TSource>! source, System.Func<System.Collections.Generic.IAsyncEnumerable<TSource>!, System.Collections.Generic.IAsyncEnumerable<TResult>!>! selector) -> System.Collections.Generic.IAsyncEnumerable<TResult>!

Source/SuperLinq.Async/PublicAPI/net8.0/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ static SuperLinq.Async.AsyncSuperEnumerable.Partition<T>(this System.Collections
66
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Partition<T, TResult>(this System.Collections.Generic.IAsyncEnumerable<T>! source, System.Func<T, bool>! predicate, System.Func<System.Collections.Generic.IAsyncEnumerable<T>!, System.Collections.Generic.IAsyncEnumerable<T>!, TResult>! resultSelector, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<TResult>
77
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Partition<T>(this System.Collections.Generic.IAsyncEnumerable<T>! source, System.Func<T, bool>! predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<(System.Collections.Generic.IAsyncEnumerable<T>! True, System.Collections.Generic.IAsyncEnumerable<T>! False)>
88
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Publish<TSource, TResult>(this System.Collections.Generic.IAsyncEnumerable<TSource>! source, System.Func<System.Collections.Generic.IAsyncEnumerable<TSource>!, System.Collections.Generic.IAsyncEnumerable<TResult>!>! selector) -> System.Collections.Generic.IAsyncEnumerable<TResult>!
9+
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Share<TSource, TResult>(this System.Collections.Generic.IAsyncEnumerable<TSource>! source, System.Func<System.Collections.Generic.IAsyncEnumerable<TSource>!, System.Collections.Generic.IAsyncEnumerable<TResult>!>! selector) -> System.Collections.Generic.IAsyncEnumerable<TResult>!

Source/SuperLinq.Async/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ static SuperLinq.Async.AsyncSuperEnumerable.Partition<T>(this System.Collections
66
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Partition<T, TResult>(this System.Collections.Generic.IAsyncEnumerable<T>! source, System.Func<T, bool>! predicate, System.Func<System.Collections.Generic.IAsyncEnumerable<T>!, System.Collections.Generic.IAsyncEnumerable<T>!, TResult>! resultSelector, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<TResult>
77
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Partition<T>(this System.Collections.Generic.IAsyncEnumerable<T>! source, System.Func<T, bool>! predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<(System.Collections.Generic.IAsyncEnumerable<T>! True, System.Collections.Generic.IAsyncEnumerable<T>! False)>
88
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Publish<TSource, TResult>(this System.Collections.Generic.IAsyncEnumerable<TSource>! source, System.Func<System.Collections.Generic.IAsyncEnumerable<TSource>!, System.Collections.Generic.IAsyncEnumerable<TResult>!>! selector) -> System.Collections.Generic.IAsyncEnumerable<TResult>!
9+
*REMOVED*static SuperLinq.Async.AsyncSuperEnumerable.Share<TSource, TResult>(this System.Collections.Generic.IAsyncEnumerable<TSource>! source, System.Func<System.Collections.Generic.IAsyncEnumerable<TSource>!, System.Collections.Generic.IAsyncEnumerable<TResult>!>! selector) -> System.Collections.Generic.IAsyncEnumerable<TResult>!

Source/SuperLinq.Async/Share.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,6 @@ public static IAsyncBuffer<TSource> Share<TSource>(this IAsyncEnumerable<TSource
1919
return new SharedBuffer<TSource>(source);
2020
}
2121

22-
/// <summary>
23-
/// Shares the source sequence within a selector function where each enumerator can fetch the next element from the
24-
/// source sequence.
25-
/// </summary>
26-
/// <typeparam name="TSource">Source sequence element type.</typeparam>
27-
/// <typeparam name="TResult">Result sequence element type.</typeparam>
28-
/// <param name="source">Source sequence.</param>
29-
/// <param name="selector">Selector function with shared access to the source sequence for each enumerator.</param>
30-
/// <returns>Sequence resulting from applying the selector function to the shared view over the source
31-
/// sequence.</returns>
32-
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see
33-
/// langword="null"/>.</exception>
34-
public static IAsyncEnumerable<TResult> Share<TSource, TResult>(
35-
this IAsyncEnumerable<TSource> source,
36-
Func<IAsyncEnumerable<TSource>, IAsyncEnumerable<TResult>> selector)
37-
{
38-
Guard.IsNotNull(source);
39-
Guard.IsNotNull(selector);
40-
41-
return Core(source, selector);
42-
43-
static async IAsyncEnumerable<TResult> Core(
44-
IAsyncEnumerable<TSource> source,
45-
Func<IAsyncEnumerable<TSource>, IAsyncEnumerable<TResult>> selector,
46-
[EnumeratorCancellation] CancellationToken cancellationToken = default)
47-
{
48-
await using var buffer = source.Share();
49-
await foreach (var i in selector(buffer).WithCancellation(cancellationToken).ConfigureAwait(false))
50-
yield return i;
51-
}
52-
}
53-
5422
private sealed class SharedBuffer<T> : IAsyncBuffer<T>
5523
{
5624
private readonly SemaphoreSlim _lock = new(initialCount: 1);

Source/SuperLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
static SuperLinq.SuperEnumerable.AggregateBy<TSource, TKey, TAccumulate>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector, System.Func<TKey, TAccumulate>! seedSelector, System.Func<TAccumulate, TSource, TAccumulate>! func, System.Collections.Generic.IEqualityComparer<TKey>? comparer = null) -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TAccumulate>>!
33
static SuperLinq.SuperEnumerable.AggregateBy<TSource, TKey, TAccumulate>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector, TAccumulate seed, System.Func<TAccumulate, TSource, TAccumulate>! func, System.Collections.Generic.IEqualityComparer<TKey>? comparer = null) -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TAccumulate>>!
44
*REMOVED*static SuperLinq.SuperEnumerable.Publish<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<System.Collections.Generic.IEnumerable<TSource>!, System.Collections.Generic.IEnumerable<TResult>!>! selector) -> System.Collections.Generic.IEnumerable<TResult>!
5+
*REMOVED*static SuperLinq.SuperEnumerable.Share<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<System.Collections.Generic.IEnumerable<TSource>!, System.Collections.Generic.IEnumerable<TResult>!>! selector) -> System.Collections.Generic.IEnumerable<TResult>!

Source/SuperLinq/PublicAPI/net7.0/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
static SuperLinq.SuperEnumerable.AggregateBy<TSource, TKey, TAccumulate>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector, System.Func<TKey, TAccumulate>! seedSelector, System.Func<TAccumulate, TSource, TAccumulate>! func, System.Collections.Generic.IEqualityComparer<TKey>? comparer = null) -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TAccumulate>>!
33
static SuperLinq.SuperEnumerable.AggregateBy<TSource, TKey, TAccumulate>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector, TAccumulate seed, System.Func<TAccumulate, TSource, TAccumulate>! func, System.Collections.Generic.IEqualityComparer<TKey>? comparer = null) -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TAccumulate>>!
44
*REMOVED*static SuperLinq.SuperEnumerable.Publish<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<System.Collections.Generic.IEnumerable<TSource>!, System.Collections.Generic.IEnumerable<TResult>!>! selector) -> System.Collections.Generic.IEnumerable<TResult>!
5+
*REMOVED*static SuperLinq.SuperEnumerable.Share<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<System.Collections.Generic.IEnumerable<TSource>!, System.Collections.Generic.IEnumerable<TResult>!>! selector) -> System.Collections.Generic.IEnumerable<TResult>!

Source/SuperLinq/PublicAPI/net8.0/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
static SuperLinq.SuperEnumerable.AggregateBy<TSource, TKey, TAccumulate>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector, System.Func<TKey, TAccumulate>! seedSelector, System.Func<TAccumulate, TSource, TAccumulate>! func, System.Collections.Generic.IEqualityComparer<TKey>? comparer = null) -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TAccumulate>>!
33
static SuperLinq.SuperEnumerable.AggregateBy<TSource, TKey, TAccumulate>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector, TAccumulate seed, System.Func<TAccumulate, TSource, TAccumulate>! func, System.Collections.Generic.IEqualityComparer<TKey>? comparer = null) -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TAccumulate>>!
44
*REMOVED*static SuperLinq.SuperEnumerable.Publish<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<System.Collections.Generic.IEnumerable<TSource>!, System.Collections.Generic.IEnumerable<TResult>!>! selector) -> System.Collections.Generic.IEnumerable<TResult>!
5+
*REMOVED*static SuperLinq.SuperEnumerable.Share<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<System.Collections.Generic.IEnumerable<TSource>!, System.Collections.Generic.IEnumerable<TResult>!>! selector) -> System.Collections.Generic.IEnumerable<TResult>!

Source/SuperLinq/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
static SuperLinq.SuperEnumerable.AggregateBy<TSource, TKey, TAccumulate>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector, System.Func<TKey, TAccumulate>! seedSelector, System.Func<TAccumulate, TSource, TAccumulate>! func, System.Collections.Generic.IEqualityComparer<TKey>? comparer = null) -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TAccumulate>>!
33
static SuperLinq.SuperEnumerable.AggregateBy<TSource, TKey, TAccumulate>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<TSource, TKey>! keySelector, TAccumulate seed, System.Func<TAccumulate, TSource, TAccumulate>! func, System.Collections.Generic.IEqualityComparer<TKey>? comparer = null) -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TAccumulate>>!
44
*REMOVED*static SuperLinq.SuperEnumerable.Publish<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<System.Collections.Generic.IEnumerable<TSource>!, System.Collections.Generic.IEnumerable<TResult>!>! selector) -> System.Collections.Generic.IEnumerable<TResult>!
5+
*REMOVED*static SuperLinq.SuperEnumerable.Share<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource>! source, System.Func<System.Collections.Generic.IEnumerable<TSource>!, System.Collections.Generic.IEnumerable<TResult>!>! selector) -> System.Collections.Generic.IEnumerable<TResult>!

Source/SuperLinq/Share.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,6 @@ public static IBuffer<TSource> Share<TSource>(this IEnumerable<TSource> source)
3535
return new SharedBuffer<TSource>(source);
3636
}
3737

38-
/// <summary>
39-
/// Shares the source sequence within a selector function where each enumerator can fetch the next element from the
40-
/// source sequence.
41-
/// </summary>
42-
/// <typeparam name="TSource">Source sequence element type.</typeparam>
43-
/// <typeparam name="TResult">Result sequence element type.</typeparam>
44-
/// <param name="source">Source sequence.</param>
45-
/// <param name="selector">Selector function with shared access to the source sequence for each enumerator.</param>
46-
/// <returns>Sequence resulting from applying the selector function to the shared view over the source
47-
/// sequence.</returns>
48-
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see
49-
/// langword="null"/>.</exception>
50-
public static IEnumerable<TResult> Share<TSource, TResult>(this IEnumerable<TSource> source, Func<IEnumerable<TSource>, IEnumerable<TResult>> selector)
51-
{
52-
Guard.IsNotNull(source);
53-
Guard.IsNotNull(selector);
54-
55-
return Core(source, selector);
56-
57-
static IEnumerable<TResult> Core(IEnumerable<TSource> source, Func<IEnumerable<TSource>, IEnumerable<TResult>> selector)
58-
{
59-
using var buffer = source.Share();
60-
foreach (var i in selector(buffer))
61-
yield return i;
62-
}
63-
}
64-
6538
private sealed class SharedBuffer<T> : IBuffer<T>
6639
{
6740
private readonly object _lock = new();

Tests/SuperLinq.Async.Test/ShareTest.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,4 @@ public IEnumerator<int> GetEnumerator()
259259

260260
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
261261
}
262-
263-
[Fact]
264-
public void ShareLambdaIsLazy()
265-
{
266-
_ = new AsyncBreakingSequence<int>().Share(BreakingFunc.Of<IAsyncEnumerable<int>, IAsyncEnumerable<string>>());
267-
}
268-
269-
[Fact]
270-
public async Task ShareLambdaSimple()
271-
{
272-
await using var seq = Enumerable.Range(0, 10).AsTestingSequence();
273-
274-
var result = seq.Share(xs => xs.Zip(xs, (l, r) => l + r).Take(4));
275-
await result.AssertSequenceEqual(1, 5, 9, 13);
276-
}
277262
}

Tests/SuperLinq.Test/ShareTest.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,4 @@ public IEnumerator<int> GetEnumerator()
259259

260260
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
261261
}
262-
263-
[Fact]
264-
public void ShareLambdaIsLazy()
265-
{
266-
_ = new BreakingSequence<int>().Share(BreakingFunc.Of<IEnumerable<int>, IEnumerable<string>>());
267-
}
268-
269-
[Fact]
270-
public void ShareLambdaSimple()
271-
{
272-
using var seq = Enumerable.Range(0, 10).AsTestingSequence();
273-
274-
var result = seq.Share(xs => xs.Zip(xs, (l, r) => l + r).Take(4));
275-
result.AssertSequenceEqual(1, 5, 9, 13);
276-
}
277262
}

0 commit comments

Comments
 (0)