diff --git a/src/libraries/System.Formats.Tar/tests/WrappedStream.cs b/src/libraries/Common/tests/System/IO/WrappedStream.cs
similarity index 98%
rename from src/libraries/System.Formats.Tar/tests/WrappedStream.cs
rename to src/libraries/Common/tests/System/IO/WrappedStream.cs
index 5697f7c09ba554..71be0b98c9a198 100644
--- a/src/libraries/System.Formats.Tar/tests/WrappedStream.cs
+++ b/src/libraries/Common/tests/System/IO/WrappedStream.cs
@@ -1,9 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.IO;
-
-namespace System.Formats.Tar
+namespace System.IO
{
public class WrappedStream : Stream
{
diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarReader.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarReader.cs
index 22c7970644b0b2..1754f2f3bcfe35 100644
--- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarReader.cs
+++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarReader.cs
@@ -82,11 +82,16 @@ public async ValueTask DisposeAsync()
{
_isDisposed = true;
- if (!_leaveOpen && _dataStreamsToDispose?.Count > 0)
+ if (!_leaveOpen)
{
- foreach (Stream s in _dataStreamsToDispose)
+ await _archiveStream.DisposeAsync().ConfigureAwait(false);
+
+ if (_dataStreamsToDispose?.Count > 0)
{
- await s.DisposeAsync().ConfigureAwait(false);
+ foreach (Stream s in _dataStreamsToDispose)
+ {
+ await s.DisposeAsync().ConfigureAwait(false);
+ }
}
}
}
diff --git a/src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj b/src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj
index 1d30aa09d0f970..7ec67c69fc964b 100644
--- a/src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj
+++ b/src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj
@@ -68,9 +68,9 @@
-
+
diff --git a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.LongFile.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.LongFile.Tests.cs
index 6fd2166e81c35f..613e30c541d1c4 100644
--- a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.LongFile.Tests.cs
+++ b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.LongFile.Tests.cs
@@ -30,7 +30,7 @@ public static IEnumerable