Skip to content

feature request: full async/await pattern stream support #223

Open
@coelacanth16

Description

@coelacanth16

Expected behavior

I could not find any related topics, except an unanswered issue "CopyToAsync fails with ZipOutputStream #167".

One of c#'s greatest features over other languages is the async/await pattern. The .net streams all support async/await since ver 4.5 and there could be major implications and performance enhancers for FileStream in particular. Is there any plan to implement this support in this library?

Activity

added
enhancementFeature request or other improvements of existing functionality
on May 12, 2018
Numpsy

Numpsy commented on Apr 5, 2020

@Numpsy
Contributor

So, I had a little bit of a look at this (partly as it's requested, partly out of thinking it might be interesting to tinker with). I initially wondered if it would be possible to start at the bottom of the stream and add it a bit at a time, but the way the zip/gzip streams are imple,ented as subclasses of the deflator streams rather than as containers causes issues with that (if you only implement the async methds of the base class, async calls on the subclasses go through to those and miss the archive specific pieces).
So, bit more of an all-in change there.

However, as a starter - I adapted a few on the unit tests to use async stream calls as a test, and those changes could be made independantly of library changes (as it stands and async calls will be forwarded to the sync versions by the base stream class, but it async methods were to be implemented later that would mean there was already a test base for them).

@piksel and comments and/or objections to the idea of adding some async tests to the existing zip test suite? (would just be variants of the existing tests but with async stream calls to start with)

piksel

piksel commented on Apr 7, 2020

@piksel
Member

No, I guess that would be fine.

self-assigned this
on Nov 22, 2020
linked a pull request that will close this issueAdd support for Filename field in GZip #351on Nov 22, 2020
linked a pull request that will close this issueSet and Get a file name internal gzip #366on Nov 22, 2020
removed their assignment
on Nov 22, 2020
added a commit that references this issue on Dec 7, 2020
ba3b30f
mark-at-tusksoft

mark-at-tusksoft commented on May 6, 2021

@mark-at-tusksoft

Running into the same issue as reported in a similar library
haf/DotNetZip.Semverd#60

 Uncaught (in promise) Error: System.NotSupportedException: Synchronous reads are not supported.
   at Microsoft.AspNetCore.Components.Forms.BrowserFileStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputBuffer.Fill()
   at ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputBuffer.ReadLeByte()
   at ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputBuffer.ReadLeShort()
   at ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputBuffer.ReadLeInt()
   at ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry()

7 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature request or other improvements of existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Participants

    @piksel@Numpsy@coelacanth16@mark-at-tusksoft

    Issue actions

      feature request: full async/await pattern stream support · Issue #223 · icsharpcode/SharpZipLib