From b6d731a04787316a551edacd76337e6ad28a5b09 Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Fri, 26 Jan 2018 13:14:32 -0800 Subject: [PATCH 1/5] [release/2.1] Revert back to preview1 packages using custom feed (#2080) * Revert back to preview1 pacakges * Leftover changes to update package versions to preview1 --- DotnetCLIVersion.txt | 2 +- NuGet.Config | 1 + SharedRuntimeVersion.txt | 2 +- scripts/package.ps1 | 2 +- tools/common.props | 2 +- tools/dependencies.props | 6 +++--- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/DotnetCLIVersion.txt b/DotnetCLIVersion.txt index d04fdeffa7e..e2fe4a98d17 100644 --- a/DotnetCLIVersion.txt +++ b/DotnetCLIVersion.txt @@ -1 +1 @@ -2.1.300-preview2-008019 +2.2.0-preview1-008003 diff --git a/NuGet.Config b/NuGet.Config index a771c3eafcd..cf8e033e95a 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -11,6 +11,7 @@ + diff --git a/SharedRuntimeVersion.txt b/SharedRuntimeVersion.txt index 4e86791333d..d788a251127 100644 --- a/SharedRuntimeVersion.txt +++ b/SharedRuntimeVersion.txt @@ -1 +1 @@ -2.1.0-preview2-26124-07 \ No newline at end of file +2.1.0-preview1-26122-01 \ No newline at end of file diff --git a/scripts/package.ps1 b/scripts/package.ps1 index 61d483f5a84..09a80d2ccbc 100644 --- a/scripts/package.ps1 +++ b/scripts/package.ps1 @@ -1,7 +1,7 @@ Param( [string]$Configuration="Debug", [string]$ApiKey, - [string]$BuildVersion=[System.DateTime]::Now.ToString('eyyMMdd-1') + [string]$BuildVersion=[System.DateTime]::Now.ToString('preview1-yyMMdd-1') ) $repoRoot = "$PSScriptRoot\.." diff --git a/tools/common.props b/tools/common.props index 95a6fdfc722..3dc192c5a59 100644 --- a/tools/common.props +++ b/tools/common.props @@ -1,7 +1,7 @@ - $([System.DateTime]::Now.ToString(eyyMMdd-1)) + $([System.DateTime]::Now.ToString(preview1-yyMMdd-1)) Microsoft Corporation, All rights reserved 0.1.0 Microsoft Corporation diff --git a/tools/dependencies.props b/tools/dependencies.props index e2cbd0b26b4..5c412f5082d 100644 --- a/tools/dependencies.props +++ b/tools/dependencies.props @@ -3,9 +3,9 @@ 2.1.0-preview2-26124-07 4.3.0 2.6.0-beta3-62316-02 - 4.5.0-preview2-26125-06 - 4.5.0-preview2-26125-06 - 4.5.0-preview2-26125-06 + 4.5.0-preview1-26126-05 + 4.5.0-preview1-26126-05 + 4.5.0-preview1-26126-05 1.9.1 15.0.0 2.2.0 From 7ce4596266db79f9250f553a4a26bab8b58dc515 Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Fri, 26 Jan 2018 14:38:38 -0800 Subject: [PATCH 2/5] Disabling test runs (#2081) --- scripts/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 388e5bef657..8e41ae62701 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -3,7 +3,7 @@ [string]$Restore="true", [string]$Version="", [string]$BuildVersion=[System.DateTime]::Now.ToString('preview1-yyMMdd-1'), - [string]$SkipTests="false" + [string]$SkipTests="true" ) Write-Host "Configuration=$Configuration." From 3653f7f15c88096f9db9f84c686c307b55e53ba7 Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Fri, 26 Jan 2018 14:58:21 -0800 Subject: [PATCH 3/5] Update dependencies.props Fix runtime version to 2.1.0-preview1-26122-01 --- tools/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/dependencies.props b/tools/dependencies.props index 5c412f5082d..2cd81a8ec04 100644 --- a/tools/dependencies.props +++ b/tools/dependencies.props @@ -1,6 +1,6 @@ - 2.1.0-preview2-26124-07 + 2.1.0-preview1-26122-01 4.3.0 2.6.0-beta3-62316-02 4.5.0-preview1-26126-05 From 36c500304f64af44698858a78edf85cb8c0fccfb Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Fri, 26 Jan 2018 16:40:40 -0800 Subject: [PATCH 4/5] Update the feed and shared framework version and re-enabling test runs (#2082) --- NuGet.Config | 2 +- SharedRuntimeVersion.txt | 2 +- scripts/build.ps1 | 2 +- tools/dependencies.props | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index cf8e033e95a..b30f94a36a4 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -11,7 +11,7 @@ - + diff --git a/SharedRuntimeVersion.txt b/SharedRuntimeVersion.txt index d788a251127..9bd3d309008 100644 --- a/SharedRuntimeVersion.txt +++ b/SharedRuntimeVersion.txt @@ -1 +1 @@ -2.1.0-preview1-26122-01 \ No newline at end of file +2.1.0-preview1-26126-02 \ No newline at end of file diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 8e41ae62701..388e5bef657 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -3,7 +3,7 @@ [string]$Restore="true", [string]$Version="", [string]$BuildVersion=[System.DateTime]::Now.ToString('preview1-yyMMdd-1'), - [string]$SkipTests="true" + [string]$SkipTests="false" ) Write-Host "Configuration=$Configuration." diff --git a/tools/dependencies.props b/tools/dependencies.props index 2cd81a8ec04..1d5856d4812 100644 --- a/tools/dependencies.props +++ b/tools/dependencies.props @@ -1,6 +1,6 @@ - 2.1.0-preview1-26122-01 + 2.1.0-preview1-26126-02 4.3.0 2.6.0-beta3-62316-02 4.5.0-preview1-26126-05 From f77472833f83452889cf42cb064b325c87a1f5f0 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 29 Jan 2018 12:19:16 -0800 Subject: [PATCH 5/5] Fix issue where GetPosition might cross outside of ROB (#2085) --- .../System/Buffers/ReadOnlyBuffer_helpers.cs | 5 ++- .../System/IO/Pipelines/Pipe.cs | 3 +- .../ReadableBufferFacts.cs | 31 ++++++++++++++++--- .../PipelineReaderWriterFacts.cs | 29 +++++++++++++++++ 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/src/System.Buffers.Primitives/System/Buffers/ReadOnlyBuffer_helpers.cs b/src/System.Buffers.Primitives/System/Buffers/ReadOnlyBuffer_helpers.cs index e16113adc19..8e7c268ac04 100644 --- a/src/System.Buffers.Primitives/System/Buffers/ReadOnlyBuffer_helpers.cs +++ b/src/System.Buffers.Primitives/System/Buffers/ReadOnlyBuffer_helpers.cs @@ -189,10 +189,9 @@ private static SequencePosition SeekMultiSegment(IMemoryList start, int st memory = memory.Slice(0, currentEnd - currentIndex); // We would prefer to put cursor in the beginning of next segment - // then past the end of previous one, but only if next exists - + // then past the end of previous one, but only if we are not leaving current buffer if (memory.Length > bytes || - (memory.Length == bytes && current.Next == null)) + (memory.Length == bytes && current == end)) { result = new SequencePosition(current, currentIndex + (int)bytes); foundResult = true; diff --git a/src/System.IO.Pipelines/System/IO/Pipelines/Pipe.cs b/src/System.IO.Pipelines/System/IO/Pipelines/Pipe.cs index 1e9a54fe046..18672baadcf 100644 --- a/src/System.IO.Pipelines/System/IO/Pipelines/Pipe.cs +++ b/src/System.IO.Pipelines/System/IO/Pipelines/Pipe.cs @@ -407,8 +407,7 @@ internal void Advance(SequencePosition consumed, SequencePosition examined) // if we are going to return commit head // we need to check that there is no writing operation that // might be using tailspace - if (consumed.Index == returnEnd.Length && - !(_commitHead == returnEnd && _writingHead != null)) + if (consumed.Index == returnEnd.Length && _writingHead != returnEnd) { var nextBlock = returnEnd.NextSegment; if (_commitHead == returnEnd) diff --git a/tests/System.Buffers.Primitives.Tests/ReadableBufferFacts.cs b/tests/System.Buffers.Primitives.Tests/ReadableBufferFacts.cs index c23cf506f25..779a6bfd62f 100644 --- a/tests/System.Buffers.Primitives.Tests/ReadableBufferFacts.cs +++ b/tests/System.Buffers.Primitives.Tests/ReadableBufferFacts.cs @@ -87,7 +87,7 @@ public void ReadableBufferDoesNotAllowSlicingOutOfRange(Action(() => buffer.GetPosition(buffer.Start, 101)); } [Fact] - public void ReadableBufferMove_DoesNotAlowNegative() + public void ReadableBufferGetPosition_DoesNotAlowNegative() { var buffer = Factory.CreateOfSize(20); Assert.Throws(() => buffer.GetPosition(buffer.Start, -1)); @@ -140,7 +140,7 @@ public void SegmentStartIsConsideredInBoundsCheck() } [Fact] - public void MovePrefersNextSegment() + public void GetPositionPrefersNextSegment() { var bufferSegment1 = new BufferSegment(); bufferSegment1.SetMemory(new OwnedArray(new byte[100]), 49, 99); @@ -157,6 +157,29 @@ public void MovePrefersNextSegment() Assert.Equal(bufferSegment2, c1.Segment); } + [Fact] + public void GetPositionDoesNotCrossOutsideBuffer() + { + var bufferSegment1 = new BufferSegment(); + bufferSegment1.SetMemory(new OwnedArray(new byte[100]), 0, 100); + + var bufferSegment2 = new BufferSegment(); + bufferSegment2.SetMemory(new OwnedArray(new byte[100]), 0, 100); + + var bufferSegment3 = new BufferSegment(); + bufferSegment3.SetMemory(new OwnedArray(new byte[100]), 0, 0); + + bufferSegment1.SetNext(bufferSegment2); + bufferSegment2.SetNext(bufferSegment3); + + var readableBuffer = new ReadOnlyBuffer(bufferSegment1, 0, bufferSegment2, 100); + + var c1 = readableBuffer.GetPosition(readableBuffer.Start, 200); + + Assert.Equal(100, c1.Index); + Assert.Equal(bufferSegment2, c1.Segment); + } + [Fact] public void Create_WorksWithArray() { diff --git a/tests/System.IO.Pipelines.Tests/PipelineReaderWriterFacts.cs b/tests/System.IO.Pipelines.Tests/PipelineReaderWriterFacts.cs index 0e0b6c630ae..72298874a17 100644 --- a/tests/System.IO.Pipelines.Tests/PipelineReaderWriterFacts.cs +++ b/tests/System.IO.Pipelines.Tests/PipelineReaderWriterFacts.cs @@ -531,5 +531,34 @@ public async Task AdvanceResetsCommitHeadIndex() awaitable = _pipe.Reader.ReadAsync(); Assert.False(awaitable.IsCompleted); } + + [Fact] + public async Task AdvanceWithGetPositionCrossingIntoWriteHeadWorks() + { + // Create two blocks + var memory = _pipe.Writer.GetMemory(1); + _pipe.Writer.Advance(memory.Length); + memory = _pipe.Writer.GetMemory(1); + _pipe.Writer.Advance(memory.Length); + await _pipe.Writer.FlushAsync(); + + // Read single block + var readResult = await _pipe.Reader.ReadAsync(); + + // Allocate more memory + memory = _pipe.Writer.GetMemory(1); + + // Create position that would cross into write head + var buffer = readResult.Buffer; + var position = buffer.GetPosition(buffer.Start, buffer.Length); + + // Return everything + _pipe.Reader.AdvanceTo(position); + + // Advance writer + _pipe.Writer.Advance(memory.Length); + _pipe.Writer.Commit(); + } + } }