Skip to content

Add ZipArchiveEntry extensions: ReadAllBytes/Text/Lines, WriteAllBytes/Text/Lines - #22

Merged
Tyrrrz merged 24 commits into
primefrom
copilot/add-extensions-for-ziparchiveentry
Apr 14, 2026
Merged

Tyrrrz merged 24 commits into
primefrom
copilot/add-extensions-for-ziparchiveentry

Conversation

Copilot AI commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

ZipArchiveEntry has no convenience API for reading/writing common data types — you must manually open the entry stream and wrap it each time.

Changes

  • PowerKit/Extensions/ZipArchiveEntryExtensions.cs — New extension block on ZipArchiveEntry with sync and async variants:

    • ReadAllBytes / WriteAllBytes
    • ReadAllText / WriteAllText — optional Encoding parameter, defaults to UTF-8
    • ReadAllLines / WriteAllLines — returns/accepts string[] / IEnumerable<string>
    • All async variants accept CancellationToken
  • PowerKit.Tests/ZipArchiveEntryExtensionsTests.cs — One test per method, exercising round-trip read/write against an in-memory ZipArchive

Example

using var archive = new ZipArchive(stream, ZipArchiveMode.Update);
var entry = archive.GetEntry("data.txt");

// Before: manual stream + reader boilerplate
// After:
var text = entry.ReadAllText();
entry.WriteAllLines(["line1", "line2", "line3"]);
var bytes = await entry.ReadAllBytesAsync(cancellationToken);

…ext, WriteAllText, ReadAllLines, WriteAllLines (sync + async)

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/8dd97e28-26a7-4047-a620-67f1d830cb84

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 14, 2026
@Tyrrrz
Tyrrrz marked this pull request as ready for review April 14, 2026 15:32
Copilot AI review requested due to automatic review settings April 14, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds convenience extension methods for ZipArchiveEntry to simplify common read/write operations (bytes, text, lines) with sync + async variants, and introduces a corresponding test suite to validate round-trip behavior against in-memory ZIP archives.

Changes:

  • Add ZipArchiveEntry extension methods: ReadAllBytes/Text/Lines + WriteAllBytes/Text/Lines with async counterparts and CancellationToken support.
  • Add a new test file with one test per method, validating basic read/write round-trips via ZipArchive in Update mode.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
PowerKit/Extensions/ZipArchiveEntryExtensions.cs New ZipArchiveEntry extensions implementing sync/async read/write helpers for bytes/text/lines.
PowerKit.Tests/ZipArchiveEntryExtensionsTests.cs New test suite covering the added extensions using an in-memory ZipArchive.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Tyrrrz and others added 4 commits April 14, 2026 18:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI requested a review from Tyrrrz April 14, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Tyrrrz and others added 7 commits April 14, 2026 19:08
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Tyrrrz

Tyrrrz commented Apr 14, 2026

Copy link
Copy Markdown
Owner

@copilot please update PolyShim to v2.9.0, I've added polyfills that should fix some of the issues you've outlined.

Copilot AI commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please update PolyShim to v2.9.0, I've added polyfills that should fix some of the issues you've outlined.

Done in d729056. PolyShim updated to 2.9.0, which adds Net80/TextWriter.cs polyfilling FlushAsync(CancellationToken). All async write methods now use CT-accepting overloads directly — no more fallback plain-string variants needed.

Copilot AI requested a review from Tyrrrz April 14, 2026 18:58
@Tyrrrz
Tyrrrz force-pushed the copilot/add-extensions-for-ziparchiveentry branch from ab76e17 to 3f4045f Compare April 14, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants