From b519aaeb6e163edaac279da1db6ffead30ad2031 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Fri, 23 Oct 2020 11:10:05 -0700 Subject: [PATCH 1/7] Throw when reader is completed with an exception --- .../src/System/IO/Pipelines/Pipe.cs | 2 +- .../tests/PipeReaderWriterFacts.cs | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs b/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs index 5637dd98393515..f90ac5b8a9b9fe 100644 --- a/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs +++ b/src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs @@ -960,7 +960,7 @@ internal ValueTask WriteAsync(ReadOnlyMemory source, Cancella ThrowHelper.ThrowInvalidOperationException_NoWritingAllowed(); } - if (_readerCompletion.IsCompleted) + if (_readerCompletion.IsCompletedOrThrow()) { return new ValueTask(new FlushResult(isCanceled: false, isCompleted: true)); } diff --git a/src/libraries/System.IO.Pipelines/tests/PipeReaderWriterFacts.cs b/src/libraries/System.IO.Pipelines/tests/PipeReaderWriterFacts.cs index 61126ab08b5995..11e0cc84cdf3d5 100644 --- a/src/libraries/System.IO.Pipelines/tests/PipeReaderWriterFacts.cs +++ b/src/libraries/System.IO.Pipelines/tests/PipeReaderWriterFacts.cs @@ -229,6 +229,34 @@ void ThrowTestException() Assert.Single(Regex.Matches(invalidOperationException.StackTrace, "Pipe.GetReadResult")); } + [Fact] + public async Task WriteAsync_ThrowsIfReaderCompletedWithException() + { + void ThrowTestException() + { + try + { + throw new InvalidOperationException("Reader exception"); + } + catch (Exception e) + { + _pipe.Reader.Complete(e); + } + } + + ThrowTestException(); + + InvalidOperationException invalidOperationException = + await Assert.ThrowsAsync(async () => await _pipe.Writer.WriteAsync(new byte[1])); + + Assert.Equal("Reader exception", invalidOperationException.Message); + Assert.Contains("ThrowTestException", invalidOperationException.StackTrace); + + invalidOperationException = await Assert.ThrowsAsync(async () => await _pipe.Writer.WriteAsync(new byte[1])); + Assert.Equal("Reader exception", invalidOperationException.Message); + Assert.Contains("ThrowTestException", invalidOperationException.StackTrace); + } + [Fact] public async Task ReaderShouldNotGetUnflushedBytes() { From 0cafe00b446d452049d5af27e687b842e5b5627c Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Tue, 27 Oct 2020 09:24:21 -0700 Subject: [PATCH 2/7] fb --- .../tests/PipeReaderWriterFacts.cs | 48 ++++++++----------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/src/libraries/System.IO.Pipelines/tests/PipeReaderWriterFacts.cs b/src/libraries/System.IO.Pipelines/tests/PipeReaderWriterFacts.cs index 11e0cc84cdf3d5..987c239c5f9428 100644 --- a/src/libraries/System.IO.Pipelines/tests/PipeReaderWriterFacts.cs +++ b/src/libraries/System.IO.Pipelines/tests/PipeReaderWriterFacts.cs @@ -4,6 +4,7 @@ using System.Buffers; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using System.Threading; @@ -199,32 +200,33 @@ public async Task HelloWorldAcrossTwoBlocks() Assert.Equal(" World", Encoding.ASCII.GetString(worldBytes)); } - [Fact] - public async Task ReadAsync_ThrowsIfWriterCompletedWithException() + [MethodImpl(MethodImplOptions.NoInlining)] + void ThrowTestException(Exception ex, Action catchAction) { - void ThrowTestException() + try { - try - { - throw new InvalidOperationException("Writer exception"); - } - catch (Exception e) - { - _pipe.Writer.Complete(e); - } + throw ex; } + catch (Exception e) + { + catchAction(e); + } + } - ThrowTestException(); + [Fact] + public async Task ReadAsync_ThrowsIfWriterCompletedWithException() + { + ThrowTestException(new InvalidOperationException("Writer exception"), e => _pipe.Writer.Complete(e)); InvalidOperationException invalidOperationException = await Assert.ThrowsAsync(async () => await _pipe.Reader.ReadAsync()); Assert.Equal("Writer exception", invalidOperationException.Message); - Assert.Contains("ThrowTestException", invalidOperationException.StackTrace); + Assert.Contains(nameof(ThrowTestException), invalidOperationException.StackTrace); invalidOperationException = await Assert.ThrowsAsync(async () => await _pipe.Reader.ReadAsync()); Assert.Equal("Writer exception", invalidOperationException.Message); - Assert.Contains("ThrowTestException", invalidOperationException.StackTrace); + Assert.Contains(nameof(ThrowTestException), invalidOperationException.StackTrace); Assert.Single(Regex.Matches(invalidOperationException.StackTrace, "Pipe.GetReadResult")); } @@ -232,29 +234,17 @@ void ThrowTestException() [Fact] public async Task WriteAsync_ThrowsIfReaderCompletedWithException() { - void ThrowTestException() - { - try - { - throw new InvalidOperationException("Reader exception"); - } - catch (Exception e) - { - _pipe.Reader.Complete(e); - } - } - - ThrowTestException(); + ThrowTestException(new InvalidOperationException("Reader exception"), e => _pipe.Reader.Complete(e)); InvalidOperationException invalidOperationException = await Assert.ThrowsAsync(async () => await _pipe.Writer.WriteAsync(new byte[1])); Assert.Equal("Reader exception", invalidOperationException.Message); - Assert.Contains("ThrowTestException", invalidOperationException.StackTrace); + Assert.Contains(nameof(ThrowTestException), invalidOperationException.StackTrace); invalidOperationException = await Assert.ThrowsAsync(async () => await _pipe.Writer.WriteAsync(new byte[1])); Assert.Equal("Reader exception", invalidOperationException.Message); - Assert.Contains("ThrowTestException", invalidOperationException.StackTrace); + Assert.Contains(nameof(ThrowTestException), invalidOperationException.StackTrace); } [Fact] From d3e596837754fb0673dad70594879727e46f408a Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Fri, 13 Nov 2020 17:13:59 -0800 Subject: [PATCH 3/7] some infra --- src/libraries/System.IO.Pipelines/Directory.Build.props | 1 + src/libraries/libraries-packages.proj | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libraries/System.IO.Pipelines/Directory.Build.props b/src/libraries/System.IO.Pipelines/Directory.Build.props index bdcfca3b543cbb..8e9ce6b83c31bd 100644 --- a/src/libraries/System.IO.Pipelines/Directory.Build.props +++ b/src/libraries/System.IO.Pipelines/Directory.Build.props @@ -2,5 +2,6 @@ Open + 5.0.1 \ No newline at end of file diff --git a/src/libraries/libraries-packages.proj b/src/libraries/libraries-packages.proj index 7729e478f710db..f9abc538adcfa1 100644 --- a/src/libraries/libraries-packages.proj +++ b/src/libraries/libraries-packages.proj @@ -18,6 +18,7 @@ + From dd4f5ce256d8bae027d050e5213a3107bd2acc0d Mon Sep 17 00:00:00 2001 From: Anirudh Agnihotry Date: Mon, 16 Nov 2020 13:34:31 -0800 Subject: [PATCH 4/7] Update the assembly version as well --- src/libraries/System.IO.Pipelines/Directory.Build.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.IO.Pipelines/Directory.Build.props b/src/libraries/System.IO.Pipelines/Directory.Build.props index 8e9ce6b83c31bd..0475bcea41e1e1 100644 --- a/src/libraries/System.IO.Pipelines/Directory.Build.props +++ b/src/libraries/System.IO.Pipelines/Directory.Build.props @@ -3,5 +3,6 @@ Open 5.0.1 + 5.0.0.1 - \ No newline at end of file + From 951158c365e86d834c94366b4d014fb4e222a362 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Wed, 18 Nov 2020 18:08:17 -0800 Subject: [PATCH 5/7] add assembly version --- src/libraries/pkg/baseline/packageIndex.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/pkg/baseline/packageIndex.json b/src/libraries/pkg/baseline/packageIndex.json index b04e38d0e2ed21..43be43d3c566d1 100644 --- a/src/libraries/pkg/baseline/packageIndex.json +++ b/src/libraries/pkg/baseline/packageIndex.json @@ -3435,7 +3435,8 @@ "4.0.0.0": "4.5.0", "4.0.0.1": "4.5.2", "4.0.1.0": "4.6.0", - "5.0.0.0": "5.0.0" + "5.0.0.0": "5.0.0", + "5.0.0.1": "5.0.1" } }, "System.IO.Pipes": { From 0031db88044e65abedcdbdc89fd3663104616072 Mon Sep 17 00:00:00 2001 From: Anipik Date: Fri, 20 Nov 2020 19:29:44 -0800 Subject: [PATCH 6/7] fix system.io.pipelines packageindex entry --- src/libraries/pkg/baseline/packageIndex.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libraries/pkg/baseline/packageIndex.json b/src/libraries/pkg/baseline/packageIndex.json index 43be43d3c566d1..b6a5cd6c06363a 100644 --- a/src/libraries/pkg/baseline/packageIndex.json +++ b/src/libraries/pkg/baseline/packageIndex.json @@ -3427,6 +3427,10 @@ "4.5.2", "4.5.3", "4.6.0", + "4.7.0", + "4.7.1", + "4.7.2", + "4.7.3", "5.0.0" ], "BaselineVersion": "5.0.0", @@ -3435,6 +3439,9 @@ "4.0.0.0": "4.5.0", "4.0.0.1": "4.5.2", "4.0.1.0": "4.6.0", + "4.0.2.0": "4.7.0", + "4.0.2.1": "4.7.1", + "4.0.2.2": "4.7.3", "5.0.0.0": "5.0.0", "5.0.0.1": "5.0.1" } From 85c0f4d63e52fc00ad24752b5ff866b2859b1e21 Mon Sep 17 00:00:00 2001 From: Anirudh Agnihotry Date: Mon, 23 Nov 2020 09:45:15 -0800 Subject: [PATCH 7/7] Fix package harvesting by passing correct versions --- eng/restore/harvestPackages.targets | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/eng/restore/harvestPackages.targets b/eng/restore/harvestPackages.targets index a7fc8aa34655f5..2e9a8155be6787 100644 --- a/eng/restore/harvestPackages.targets +++ b/eng/restore/harvestPackages.targets @@ -1,16 +1,21 @@ - + - - - <_AllPkgProjs Include="$(LibrariesProjectRoot)*\pkg\**\*.pkgproj" /> - - + + - <_AllPkgProjsToPackageIdentity Include="@(_AllPkgProjs -> '%(Filename)')" /> + <_AllPkgProjs Include="$(LibrariesProjectRoot)*\pkg\**\*.pkgproj"> + MSBuildRestoreSessionId + + + + + + +