Skip to content

Commit 4822342

Browse files
committed
ValueTask usage cleanups
1 parent ca8d75f commit 4822342

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

CSRakowski.AsyncStreamsPreparations.Tests/BasicApiTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public async Task SimpleForeachLogic()
2121
long summedTotal = 0;
2222
try
2323
{
24-
while (await enumerator.MoveNextAsync())
24+
while (await enumerator.MoveNextAsync().ConfigureAwait(false))
2525
{
2626
int current = enumerator.Current;
2727
summedTotal += current;
2828
}
2929
}
3030
finally
3131
{
32-
await enumerator.DisposeAsync();
32+
await enumerator.DisposeAsync().ConfigureAwait(false);
3333
}
3434

3535
Assert.That(expectedSum == summedTotal, "Summed total should be {0}, but was found to be {1}", expectedSum, summedTotal);

CSRakowski.AsyncStreamsPreparations.Tests/CSRakowski.AsyncStreamsPreparations.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Authors>Christiaan Rakowski</Authors>
99
<Copyright>Christiaan Rakowski - 2018-2021</Copyright>
1010
<LangVersion>latest</LangVersion>
11-
<Version>1.3.0</Version>
11+
<Version>1.4.1</Version>
1212
<RootNamespace>CSRakowski.AsyncStreamsPreparations.Tests</RootNamespace>
1313
<AssemblyName>CSRakowski.AsyncStreamsPreparations.Tests</AssemblyName>
1414

CSRakowski.AsyncStreamsPreparations/AsyncEnumerable.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal AsyncEnumerator(IEnumerator<T> enumerator)
5353
/// of the collection.
5454
/// </returns>
5555
public ValueTask<bool> MoveNextAsync() =>
56-
new ValueTask<bool>(Task.FromResult(_enumerator.MoveNext()));
56+
new ValueTask<bool>(_enumerator.MoveNext());
5757

5858
/// <summary>
5959
/// Gets the element in the collection at the current position of the enumerator.
@@ -70,6 +70,8 @@ public ValueTask DisposeAsync()
7070

7171
#if NETSTANDARD1_1
7272
return new ValueTask(Task.FromResult(true));
73+
#elif NET5_0_OR_GREATER
74+
return ValueTask.CompletedTask;
7375
#else
7476
return new ValueTask(Task.CompletedTask);
7577
#endif

CSRakowski.AsyncStreamsPreparations/CSRakowski.AsyncStreamsPreparations.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<LangVersion>latest</LangVersion>
1616
<SignAssembly>true</SignAssembly>
1717
<AssemblyOriginatorKeyFile>CSRakowski.AsyncStreamsPreparations.snk</AssemblyOriginatorKeyFile>
18-
<PackageReleaseNotes>* Dropped netcoreapp3.0.</PackageReleaseNotes>
19-
<Version>1.4.0</Version>
18+
<PackageReleaseNotes>* ValueTask usage cleanups.</PackageReleaseNotes>
19+
<Version>1.4.1</Version>
2020
</PropertyGroup>
2121

2222
<PropertyGroup Condition="'$(TargetFramework)' == 'net50' or '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'netstandard2.1'">

0 commit comments

Comments
 (0)