Thanks to visit codestin.com
Credit goes to github.com

Skip to content

VS 16.2.0 regression: CopyToAsync from DeflateStream to GzipStream throws NotImplementedException #16122

@steveisok

Description

@steveisok

Copied from dotnet/android#3397

Steps to Reproduce

  1. Use the ZipArchive and ZipArchiveEntry classes to open a stream to an entry in a zip file
  2. Set up a GZipStream compressing to a MemoryStream
  3. Copy the zip entry stream to the GZipStream
  4. Observe the NotImplementedException

Repro project: https://github.com/mfeingol/repros/tree/master/Xamarin.Android-3397-CopyToAsync

Expected Behavior

Stream copy is successful, as it was in prior versions of the Mono runtime.

Actual Behavior

NotImplementedException:

  at System.IO.Compression.DeflateStream.WriteAsyncMemory (System.ReadOnlyMemory`1[T] source, System.Threading.CancellationToken cancellationToken) [0x00000] in <ca7419b40e504a6dbe088f6fe95d09aa>:0 
  at (wrapper remoting-invoke-with-check) System.IO.Compression.DeflateStream.WriteAsyncMemory(System.ReadOnlyMemory`1<byte>,System.Threading.CancellationToken)
  at System.IO.Compression.GZipStream.WriteAsync (System.ReadOnlyMemory`1[T] buffer, System.Threading.CancellationToken cancellationToken) [0x00026] in <ca7419b40e504a6dbe088f6fe95d09aa>:0 
  at System.IO.Stream.CopyToAsyncInternal (System.IO.Stream destination, System.Int32 bufferSize, System.Threading.CancellationToken cancellationToken) [0x000c7] in <ff07eae8184a40a08e79049bbcb31a0e>:0 
  at CopyToAsync.MainPage.Repro (System.Object sender, System.EventArgs args) [0x0008a] in C:\Users\mfeingol\source\Repos\CopyToAsync\CopyToAsync\CopyToAsync\MainPage.xaml.cs:35 

Example code:

ZipArchive archive = new ZipArchive(ZipFile, ZipArchiveMode.Read, true, Encoding.UTF8);
ZipArchiveEntry entry = archive.GetEntry("a4.jpg");
Stream src = entry.Open();

MemoryStream dest = new MemoryStream();

using (GZipStream gzip = new GZipStream(dest, CompressionLevel.Optimal, true))
    await src.CopyToAsync(gzip);

byte[] compressed = dest.ToArray();

Version Information

VS 16.2.0, fresh project from new project wizard, latest Xamarin.Forms Nuget packages (not that it's relevant)

Log File

log.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions