Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Commonly Used Types:
System.IO.Pipelines.Pipe
System.IO.Pipelines.PipeWriter
System.IO.Pipelines.PipeReader</PackageDescription>
<ServicingVersion>1</ServicingVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ServicingVersion>2</ServicingVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(CommonPath)System\Threading\Tasks\TaskToApm.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ private void WriteMultiSegment(ReadOnlySpan<byte> source)
}

// We filled the segment
_writingHead.End += writable;
_writingHead.End += _writingHeadBytesBuffered;
_writingHeadBytesBuffered = 0;

// This is optimized to use pooled memory. That's why we pass 0 instead of
Expand Down
14 changes: 14 additions & 0 deletions src/libraries/System.IO.Pipelines/tests/PipeLengthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,19 @@ public async Task NullExaminedAndConsumedNoops()
ReadResult result = await _pipe.Reader.ReadAsync();
_pipe.Reader.AdvanceTo(default, default);
}

[Fact]
public async Task AdvanceFollowedByWriteAsyncTest()
{
Memory<byte> buffer = new byte[26];
Pipe pipe = new(new PipeOptions(minimumSegmentSize: 1));

var mem = pipe.Writer.GetMemory(14)[..14];
buffer[..14].CopyTo(mem);
pipe.Writer.Advance(14);
await pipe.Writer.WriteAsync(buffer[14..]);
ReadResult res = await pipe.Reader.ReadAsync();
Assert.Equal(res.Buffer.Length, buffer.Length);
}
}
}