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:
JT
2019-10-23 10:50:12 +08:00
committed by Christopher F
parent a61adb07e0
commit d199d93ae4
23 changed files with 84 additions and 100 deletions

View File

@@ -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;
}
}
}
}