meta: Fix .NET Core 3.0 compatibility + Drop NS1.3 (#1382)
* Update all dependencies and deal with warning/errors * Add updated AsyncEnumerable implementation * Fix broken target * Cleanup * Remove obsolete message * typo * Update azure pipelines * Update samples to .NET Core 3.0 * Pull out test change * Install the .net core 3 SDK on the ubuntu image for the time being * Target net core 3 for the unit tests because pipelines
This commit is contained in:
@@ -25,26 +25,28 @@ namespace Discord
|
||||
_nextPage = nextPage;
|
||||
}
|
||||
|
||||
public IAsyncEnumerator<IReadOnlyCollection<T>> GetEnumerator() => new Enumerator(this);
|
||||
public IAsyncEnumerator<IReadOnlyCollection<T>> GetAsyncEnumerator(CancellationToken cancellationToken = new CancellationToken()) => new Enumerator(this, cancellationToken);
|
||||
internal class Enumerator : IAsyncEnumerator<IReadOnlyCollection<T>>
|
||||
{
|
||||
private readonly PagedAsyncEnumerable<T> _source;
|
||||
private readonly CancellationToken _token;
|
||||
private readonly PageInfo _info;
|
||||
|
||||
public IReadOnlyCollection<T> Current { get; private set; }
|
||||
|
||||
public Enumerator(PagedAsyncEnumerable<T> source)
|
||||
public Enumerator(PagedAsyncEnumerable<T> source, CancellationToken token)
|
||||
{
|
||||
_source = source;
|
||||
_token = token;
|
||||
_info = new PageInfo(source._start, source._count, source.PageSize);
|
||||
}
|
||||
|
||||
public async Task<bool> MoveNext(CancellationToken cancelToken)
|
||||
public async ValueTask<bool> MoveNextAsync()
|
||||
{
|
||||
if (_info.Remaining == 0)
|
||||
return false;
|
||||
|
||||
var data = await _source._getPage(_info, cancelToken).ConfigureAwait(false);
|
||||
var data = await _source._getPage(_info, _token).ConfigureAwait(false);
|
||||
Current = new Page<T>(_info, data);
|
||||
|
||||
_info.Page++;
|
||||
@@ -71,7 +73,11 @@ namespace Discord
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Dispose() { Current = null; }
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
Current = null;
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user