Skip to content

Add PowerKit, replace own utilities, update PolyShim and CSharpier#89

Merged
Tyrrrz merged 9 commits intoprimefrom
copilot/add-powerkit-package-and-update-utilities
Apr 16, 2026
Merged

Add PowerKit, replace own utilities, update PolyShim and CSharpier#89
Tyrrrz merged 9 commits intoprimefrom
copilot/add-powerkit-package-and-update-utilities

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 16, 2026

Adopts PowerKit 0.0.0-a.5 across Onova, Onova.Updater, and Onova.Tests, replacing hand-rolled utility classes with PowerKit equivalents. Also bumps PolyShim 2.7.0 → 2.10.0 and CSharpier.MsBuild 1.2.1 → 1.2.6 with a re-format pass.

Replaced utilities

Onova — deleted in favour of PowerKit:

  • Utils/LockFile.csPowerKit.LockFile
  • Utils/PooledBuffer.cs → PowerKit's internal MemoryPool<byte> usage
  • Utils/Extensions/DirectoryExtensions.csPowerKit.Extensions.DirectoryExtensions (Reset, CheckWriteAccess)
  • Utils/Extensions/FileExtensions.csPowerKit.Extensions.FileExtensions (CheckWriteAccess)
  • Utils/Extensions/ReflectionExtensions.csPowerKit.Extensions.AssemblyExtensions (ExtractManifestResourceAsync)
  • Utils/Extensions/StreamExtensions.csPowerKit.Extensions.StreamExtensions (CopyToAsync with progress)
  • Utils/Extensions/StringExtensions.cs → inlined Convert.ToBase64String(Encoding.UTF8.GetBytes(...))

Onova.Updater — deleted:

  • Utils/Disposable.csPowerKit.Disposable
  • Utils/FileEx.csPowerKit.Extensions.FileExtensions.CheckWriteAccess
  • Utils/Extensions/BinaryExtensions.cs → inlined Encoding.UTF8.GetString(Convert.FromBase64String(...)) directly in Program.cs
  • Utils/Extensions/DirectoryEx.csPowerKit.Extensions.DirectoryExtensions.Copy (now provided by PowerKit 0.0.0-a.5)

Onova.Tests — deleted:

  • Utils/Extensions/DirectoryExtensions.csPowerKit.Extensions.DirectoryExtensions (Reset, TryDelete)
  • Utils/Extensions/ZipExtensions.csPowerKit.Extensions.ZipArchiveEntryExtensions (WriteAllBytes, ReadAllText)

All test spec classes (Resolving/ × 5, Extracting/ × 2, UpdateSpecs) now use PowerKit.TempDirectory.Create() instead of the manual TempDirPath + Directory.Reset() + Directory.TryDelete() pattern, eliminating the boilerplate per class.

Notable details

  • HttpClientExtensions.CopyToStreamAsync now delegates to PowerKit's stream.CopyToAsync(destination, contentLength, progress, ct), eliminating the manual read loop.
  • The NugetPackageExtractor and ZipPackageExtractor extractors use progress?.Pipe(...) to inline the per-entry progress adapter directly into the CopyToAsync call, capturing entryBaseOffset before the lambda to avoid stale-closure issues with the mutable totalBytesCopied:
var entryBaseOffset = totalBytesCopied;
await input.CopyToAsync(
    output,
    entry.Length,
    progress?.Pipe(p =>
        new Progress<double>(entryP =>
            p.Report(
                (entryBaseOffset + (long)(entryP * entry.Length)) / (double)totalBytes
            )
        )
    ),
    cancellationToken
);
  • For retry-loop delete sites in tests (UpdateSpecs.Dispose, DummyEnvironment.Cleanup) that must distinguish DirectoryNotFoundException from UnauthorizedAccessException, Directory.Delete is used directly rather than TempDirectory.Dispose or Directory.TryDelete, since the latter swallows all exceptions.

@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 16, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review April 16, 2026 14:58
Copilot AI review requested due to automatic review settings April 16, 2026 14:58
Comment thread Onova.Tests/Resolving/LocalSourceSpecs.cs Outdated
Comment thread Onova/Services/NugetPackageExtractor.cs Outdated
Comment thread Onova/Services/ZipPackageExtractor.cs Outdated
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adopts PowerKit across the solution to replace several home-grown utility helpers, while also updating PolyShim/CSharpier and applying a formatting pass.

Changes:

  • Replace custom IO helpers (lock file, pooled buffers, stream/string/IO extensions) with PowerKit equivalents.
  • Refactor package extraction/downloading code to use PowerKit’s CopyToAsync overloads (including progress reporting).
  • Update central package versions (PolyShim, CSharpier.MsBuild) and add PowerKit to projects.

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Onova/Utils/PooledBuffer.cs Deleted; previously wrapped ArrayPool for streaming buffers.
Onova/Utils/LockFile.cs Deleted; replaced by PowerKit.LockFile.
Onova/Utils/Extensions/StringExtensions.cs Deleted; base64 conversion inlined and other helpers assumed to come from PowerKit.
Onova/Utils/Extensions/StreamExtensions.cs Deleted; stream copy w/ progress now delegated to PowerKit.
Onova/Utils/Extensions/ReflectionExtensions.cs Deleted; manifest resource extraction now expected via PowerKit extensions.
Onova/Utils/Extensions/HttpClientExtensions.cs Switches HTTP content copy to PowerKit stream copy w/ length/progress support.
Onova/Utils/Extensions/FileExtensions.cs Deleted; write-access check now expected via PowerKit.
Onova/Utils/Extensions/DirectoryExtensions.cs Deleted; directory reset/write-access now expected via PowerKit.
Onova/UpdateManager.cs Uses PowerKit lock file + PowerKit IO extensions; inlines base64 arg routing.
Onova/Services/ZipPackageExtractor.cs Uses PowerKit CopyToAsync and introduces per-entry progress adapter.
Onova/Services/WebPackageResolver.cs Uses PowerKit string extensions and keeps download flow via existing HttpClient extensions.
Onova/Services/NugetPackageExtractor.cs Uses PowerKit CopyToAsync and introduces per-entry progress adapter.
Onova/Services/LocalPackageResolver.cs Uses PowerKit stream copy overload for file-to-file downloads with progress.
Onova/Services/GithubPackageResolver.cs Formatting-only tweak to release name parsing.
Onova/Onova.csproj Adds PowerKit package reference.
Onova.Updater/Utils/FileEx.cs Deleted; file write-access check moved to PowerKit.
Onova.Updater/Utils/Disposable.cs Deleted; no longer needed after refactors.
Onova.Updater/Updater.cs Switches to PowerKit File.CheckWriteAccess.
Onova.Updater/Onova.Updater.csproj Adds PowerKit package reference.
Onova.Tests/Utils/Extensions/ZipExtensions.cs Deleted; Zip entry helpers moved to PowerKit extensions.
Onova.Tests/Utils/Extensions/DirectoryExtensions.cs Deleted; directory helpers moved to PowerKit extensions.
Onova.Tests/Utils/DummyEnvironment.cs Adjusts cleanup deletion to preserve exception semantics via direct Directory.Delete.
Onova.Tests/UpdateSpecs.cs Replaces directory helpers with PowerKit + direct delete retry loop; uses Directory.TryDelete for storage cleanup.
Onova.Tests/Resolving/WebSourceSpecs.cs Uses PowerKit directory helpers (Reset, TryDelete).
Onova.Tests/Resolving/NugetSourceSpecs.cs Uses PowerKit directory helpers (Reset, TryDelete).
Onova.Tests/Resolving/LocalSourceSpecs.cs Uses PowerKit directory helpers (Reset, TryDelete).
Onova.Tests/Resolving/GithubSourceSpecs.cs Uses PowerKit directory helpers (Reset, TryDelete).
Onova.Tests/Resolving/AggregateSourceSpecs.cs Uses PowerKit directory helpers (Reset, TryDelete).
Onova.Tests/Onova.Tests.csproj Adds PowerKit package reference.
Onova.Tests/Extracting/ZipPackageSpecs.cs Uses PowerKit directory helpers and zip entry write helper.
Onova.Tests/Extracting/NugetPackageSpecs.cs Uses PowerKit directory helpers and zip entry write helper.
Directory.Packages.props Bumps PolyShim/CSharpier and adds central PowerKit version.
Directory.Build.props Removes stray blank lines (formatting cleanup).

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

Comment thread Onova/Services/ZipPackageExtractor.cs Outdated
Comment thread Onova/Services/NugetPackageExtractor.cs Outdated
Comment thread Onova/Onova.csproj
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 16, 2026

@copilot might as well inline these: https://github.com/Tyrrrz/Onova/blob/copilot/add-powerkit-package-and-update-utilities/Onova.Updater/Utils/Extensions/BinaryExtensions.cs

Done in 2486c00. Program.cs now inlines Encoding.UTF8.GetString(Convert.FromBase64String(args[3])) directly, and BinaryExtensions.cs has been deleted.

@Tyrrrz Tyrrrz requested a review from Copilot April 16, 2026 15:13
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 64.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.56%. Comparing base (cbe9095) to head (a886664).
⚠️ Report is 2 commits behind head on prime.

Files with missing lines Patch % Lines
Onova/Services/NugetPackageExtractor.cs 60.00% 3 Missing and 1 partial ⚠️
Onova/Services/ZipPackageExtractor.cs 60.00% 3 Missing and 1 partial ⚠️
Onova/UpdateManager.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            prime      #89      +/-   ##
==========================================
- Coverage   72.15%   70.56%   -1.59%     
==========================================
  Files          28       21       -7     
  Lines         553      479      -74     
  Branches       75       65      -10     
==========================================
- Hits          399      338      -61     
+ Misses        129      119      -10     
+ Partials       25       22       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 16, 2026

@copilot instead of DisposeAll() you can use Disposable.Merge(...).Dispose()

…DisposableExtensions

Agent-Logs-Url: https://github.com/Tyrrrz/Onova/sessions/11aa7b32-e8f3-4045-8a68-f468641d870d

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 16, 2026

@copilot instead of DisposeAll() you can use Disposable.Merge(...).Dispose()

Done in e3e45ad. DirectoryEx.cs now uses Disposable.Merge(...).Dispose() and DisposableExtensions.cs has been deleted.

Copilot AI requested a review from Tyrrrz April 16, 2026 15:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 37 out of 37 changed files in this pull request and generated 3 comments.


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

Comment thread Onova/Services/ZipPackageExtractor.cs Outdated
Comment thread Onova/Services/NugetPackageExtractor.cs Outdated
Comment thread Onova.Updater/Onova.Updater.csproj
… and NugetPackageExtractor

Agent-Logs-Url: https://github.com/Tyrrrz/Onova/sessions/c0509de2-2ce7-4075-949e-90091114d28c

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Comment thread Onova.Updater/Utils/Extensions/DirectoryEx.cs Outdated
Copilot AI requested a review from Tyrrrz April 16, 2026 15:31
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 16, 2026

@copilot update PowerKit and PolyShim, and you should get Directory.Copy. Run dotnet build to reformat everything afterward.

…toryEx.cs, reformat

Agent-Logs-Url: https://github.com/Tyrrrz/Onova/sessions/23efc8d5-0e30-460b-9892-32cfc1ab06a8

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 16, 2026

@copilot update PowerKit and PolyShim, and you should get Directory.Copy. Run dotnet build to reformat everything afterward.

Done in a886664. Updated PowerKit 0.0.0-a.40.0.0-a.5 and PolyShim 2.9.02.10.0. Directory.Copy is now provided by PowerKit, so DirectoryEx.cs and its using in Updater.cs have been deleted. Ran dotnet build for the CSharpier reformat pass.

@Tyrrrz Tyrrrz merged commit f9451f7 into prime Apr 16, 2026
5 checks passed
@Tyrrrz Tyrrrz deleted the copilot/add-powerkit-package-and-update-utilities branch April 16, 2026 19:59
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