Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Mar 2, 2018
1 parent 6197519 commit 276d656
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ public override async Task WriteAsync(byte[] buffer, int offset, int count, Canc
// While there's more decompressed data available, forward it to the destination stream.
while (true)
{
int bytesRead = _deflateStream._inflater.Inflate(_arrayPoolBuffer, 0, _arrayPoolBuffer.Length);
int bytesRead = _deflateStream._inflater.Inflate(new Span<byte>(_arrayPoolBuffer));
if (bytesRead > 0)
{
await _destination.WriteAsync(new ReadOnlyMemory<byte>(_arrayPoolBuffer, 0, bytesRead), cancellationToken).ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion src/System.IO.FileSystem/src/System/IO/File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ private static async Task InternalWriteAllBytesAsync(string path, byte[] bytes,

using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, DefaultBufferSize, FileOptions.Asynchronous | FileOptions.SequentialScan))
{
await fs.WriteAsync(new ReadOnlyMemory<byte>(bytes, 0, bytes.Length), cancellationToken).ConfigureAwait(false);
await fs.WriteAsync(new ReadOnlyMemory<byte>(bytes), cancellationToken).ConfigureAwait(false);
await fs.FlushAsync(cancellationToken).ConfigureAwait(false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/System.Net.Sockets/src/System.Net.Sockets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,9 @@
<Reference Include="System.Security.Claims" />
<Reference Include="System.Security.Principal.Windows" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.ThreadPool" />
<Reference Include="System.Threading.Overlapped" />
<Reference Include="System.Threading.Tasks" />
<Reference Include="System.Threading.ThreadPool" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Reference Include="System.Threading.ThreadPool" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ private void InvokeContinuation(Action<object> continuation, object state, bool
/// <summary>Gets the result of the completion operation.</summary>
/// <returns>Number of bytes transferred.</returns>
/// <remarks>
/// Unlike Task's awaiter's GetResult, this does not block until the operation completes: it must only
/// Unlike TaskAwaiter's GetResult, this does not block until the operation completes: it must only
/// be used once the operation has completed. This is handled implicitly by await.
/// </remarks>
public int GetResult(short token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public async Task ReadWrite_Memory_LargeWrite_Success()
{
await RunWithConnectedNetworkStreamsAsync(async (server, client) =>
{
byte[] writeBuffer = new byte[10 * 1024 * 1024];
byte[] readBuffer = new byte[writeBuffer.Length];
var writeBuffer = new byte[10 * 1024 * 1024];
var readBuffer = new byte[writeBuffer.Length];
RandomNumberGenerator.Fill(writeBuffer);
ValueTask writeTask = client.WriteAsync((ReadOnlyMemory<byte>)writeBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,8 @@
<ItemGroup>
<EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@
<Name>PerfRunner</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
<Name>PerfRunner</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.ThreadPool" />
<Reference Include="System.Threading.Tasks" />
<Reference Include="System.Threading.Tasks.Extensions" />
<Reference Include="System.Threading.ThreadPool" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
28 changes: 14 additions & 14 deletions src/System.Threading.Tasks.Extensions/tests/ValueTaskTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public void Generic_CreateFromNullTask_Throws()
public void NonGeneric_CreateFromTask_AsTaskIdempotent()
{
Task source = Task.FromResult(42);
ValueTask t = new ValueTask(source);
var t = new ValueTask(source);
Assert.Same(source, t.AsTask());
Assert.Same(t.AsTask(), t.AsTask());
}
Expand All @@ -326,30 +326,30 @@ public void NonGeneric_CreateFromTask_AsTaskIdempotent()
public void Generic_CreateFromTask_AsTaskIdempotent()
{
Task<int> source = Task.FromResult(42);
ValueTask<int> t = new ValueTask<int>(source);
var t = new ValueTask<int>(source);
Assert.Same(source, t.AsTask());
Assert.Same(t.AsTask(), t.AsTask());
}

[Fact]
public void NonGeneric_CreateFromDefault_AsTaskIdempotent()
{
ValueTask t = new ValueTask();
var t = new ValueTask();
Assert.Same(t.AsTask(), t.AsTask());
}

[Fact]
public void Generic_CreateFromValue_AsTaskNotIdempotent()
{
ValueTask<int> t = new ValueTask<int>(42);
var t = new ValueTask<int>(42);
Assert.NotSame(Task.FromResult(42), t.AsTask());
Assert.NotSame(t.AsTask(), t.AsTask());
}

[Fact]
public void NonGeneric_CreateFromValueTaskSource_AsTaskIdempotent() // validates unsupported behavior specific to the backing IValueTaskSource
{
ValueTask vt = new ValueTask(ManualResetValueTaskSource.Completed<int>(42, null), 0);
var vt = new ValueTask(ManualResetValueTaskSource.Completed<int>(42, null), 0);
Task t = vt.AsTask();
Assert.NotNull(t);
Assert.Same(t, vt.AsTask());
Expand All @@ -359,7 +359,7 @@ public void NonGeneric_CreateFromValueTaskSource_AsTaskIdempotent() // validates
[Fact]
public void Generic_CreateFromValueTaskSource_AsTaskNotIdempotent() // validates unsupported behavior specific to the backing IValueTaskSource
{
ValueTask<int> t = new ValueTask<int>(ManualResetValueTaskSource.Completed<int>(42, null), 0);
var t = new ValueTask<int>(ManualResetValueTaskSource.Completed<int>(42, null), 0);
Assert.NotSame(Task.FromResult(42), t.AsTask());
Assert.NotSame(t.AsTask(), t.AsTask());
}
Expand All @@ -369,7 +369,7 @@ public void Generic_CreateFromValueTaskSource_AsTaskNotIdempotent() // validates
[InlineData(true)]
public async Task NonGeneric_CreateFromValueTaskSource_Success(bool sync)
{
ValueTask vt = new ValueTask(sync ? ManualResetValueTaskSource.Completed(0) : ManualResetValueTaskSource.Delay(1, 0), 0);
var vt = new ValueTask(sync ? ManualResetValueTaskSource.Completed(0) : ManualResetValueTaskSource.Delay(1, 0), 0);
Task t = vt.AsTask();
if (sync)
{
Expand All @@ -383,7 +383,7 @@ public async Task NonGeneric_CreateFromValueTaskSource_Success(bool sync)
[InlineData(true)]
public async Task Generic_CreateFromValueTaskSource_Success(bool sync)
{
ValueTask<int> vt = new ValueTask<int>(sync ? ManualResetValueTaskSource.Completed(42) : ManualResetValueTaskSource.Delay(1, 42), 0);
var vt = new ValueTask<int>(sync ? ManualResetValueTaskSource.Completed(42) : ManualResetValueTaskSource.Delay(1, 42), 0);
Task<int> t = vt.AsTask();
if (sync)
{
Expand All @@ -397,7 +397,7 @@ public async Task Generic_CreateFromValueTaskSource_Success(bool sync)
[InlineData(true)]
public async Task NonGeneric_CreateFromValueTaskSource_Faulted(bool sync)
{
ValueTask vt = new ValueTask(sync ? ManualResetValueTaskSource.Completed(0, new FormatException()) : ManualResetValueTaskSource.Delay(1, 0, new FormatException()), 0);
var vt = new ValueTask(sync ? ManualResetValueTaskSource.Completed(0, new FormatException()) : ManualResetValueTaskSource.Delay(1, 0, new FormatException()), 0);
Task t = vt.AsTask();
if (sync)
{
Expand All @@ -415,7 +415,7 @@ public async Task NonGeneric_CreateFromValueTaskSource_Faulted(bool sync)
[InlineData(true)]
public async Task Generic_CreateFromValueTaskSource_Faulted(bool sync)
{
ValueTask<int> vt = new ValueTask<int>(sync ? ManualResetValueTaskSource.Completed(0, new FormatException()) : ManualResetValueTaskSource.Delay(1, 0, new FormatException()), 0);
var vt = new ValueTask<int>(sync ? ManualResetValueTaskSource.Completed(0, new FormatException()) : ManualResetValueTaskSource.Delay(1, 0, new FormatException()), 0);
Task<int> t = vt.AsTask();
if (sync)
{
Expand All @@ -433,7 +433,7 @@ public async Task Generic_CreateFromValueTaskSource_Faulted(bool sync)
[InlineData(true)]
public async Task NonGeneric_CreateFromValueTaskSource_Canceled(bool sync)
{
ValueTask vt = new ValueTask(sync ? ManualResetValueTaskSource.Completed(0, new OperationCanceledException()) : ManualResetValueTaskSource.Delay(1, 0, new OperationCanceledException()), 0);
var vt = new ValueTask(sync ? ManualResetValueTaskSource.Completed(0, new OperationCanceledException()) : ManualResetValueTaskSource.Delay(1, 0, new OperationCanceledException()), 0);
Task t = vt.AsTask();
if (sync)
{
Expand All @@ -451,7 +451,7 @@ public async Task NonGeneric_CreateFromValueTaskSource_Canceled(bool sync)
[InlineData(true)]
public async Task Generic_CreateFromValueTaskSource_Canceled(bool sync)
{
ValueTask<int> vt = new ValueTask<int>(sync ? ManualResetValueTaskSource.Completed(0, new OperationCanceledException()) : ManualResetValueTaskSource.Delay(1, 0, new OperationCanceledException()), 0);
var vt = new ValueTask<int>(sync ? ManualResetValueTaskSource.Completed(0, new OperationCanceledException()) : ManualResetValueTaskSource.Delay(1, 0, new OperationCanceledException()), 0);
Task<int> t = vt.AsTask();
if (sync)
{
Expand Down Expand Up @@ -599,7 +599,7 @@ public async Task Generic_CreateFromTask_Await_Normal(bool? continueOnCapturedCo
public async Task CreateFromValueTaskSource_Await_Normal(bool? continueOnCapturedContext)
{
var mre = new ManualResetValueTaskSource<int>();
ValueTask t = new ValueTask(mre, 0);
var t = new ValueTask(mre, 0);
var ignored = Task.Delay(1).ContinueWith(_ => mre.SetResult(42));
switch (continueOnCapturedContext)
{
Expand All @@ -615,7 +615,7 @@ public async Task CreateFromValueTaskSource_Await_Normal(bool? continueOnCapture
public async Task Generic_CreateFromValueTaskSource_Await_Normal(bool? continueOnCapturedContext)
{
var mre = new ManualResetValueTaskSource<int>();
ValueTask<int> t = new ValueTask<int>(mre, 0);
var t = new ValueTask<int>(mre, 0);
var ignored = Task.Delay(1).ContinueWith(_ => mre.SetResult(42));
switch (continueOnCapturedContext)
{
Expand Down

0 comments on commit 276d656

Please sign in to comment.