Skip to content

Integrate PowerKit source package, removing redundant internal utilities - #327

Merged
Tyrrrz merged 9 commits into
primefrom
copilot/add-powerkit-package-and-remove-utils
Apr 18, 2026
Merged

Tyrrrz merged 9 commits into
primefrom
copilot/add-powerkit-package-and-remove-utils

Conversation

Copilot AI commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Replaces several hand-rolled utility/extension types with equivalents from the PowerKit source package (0.0.0-a.8), reducing internal code surface across all projects. Also reorganizes native interop code into dedicated Native/ folders.

Removed (now provided by PowerKit)

CliWrap

  • Utils/Disposable.cs → PowerKit.Disposable
  • Utils/Extensions/AssemblyExtensions.cs → PowerKit.Extensions.AssemblyExtensions
  • Utils/Extensions/ExceptionExtensions.cs → PowerKit.Extensions.AggregateExceptionExtensions
  • Utils/Extensions/StreamExtensions.cs → PowerKit.Extensions.StreamExtensions
  • Utils/Extensions/TextReaderExtensions.cs → PowerKit.Extensions.TextReaderExtensions
  • Utils/Observable.cs → PowerKit.Observable
  • Utils/SynchronizedObserver.cs → PowerKit.SynchronizedObserver
  • Utils/Extensions/AsyncDisposableExtensions.cs → PowerKit.Extensions.AsyncDisposableExtensions
  • Utils/Extensions/StringExtensions.cs → PowerKit.Extensions.StringExtensions
  • Channel<T>._isItemAvailable + _item fields → PowerKit.Cell<T> (using Store, TryOpen, and Clear)

CliWrap.Tests

  • Utils/Extensions/ProcessExtensions.cs → PowerKit.Extensions.ProcessExtensions
  • Utils/TempDir.cs → PowerKit.TempDirectory
  • Utils/TempFile.cs → PowerKit.TempFile
  • Utils/Extensions/EnvironmentExtensions.cs updated to use PowerKit.Disposable instead of System.Reactive.Disposables.Disposable

Moved

  • CliWrap/Utils/NativeMethods.cs → CliWrap/Native/NativeMethods.cs (namespace CliWrap.Native)
  • CliWrap/Utils/WindowsSignaler.cs → CliWrap/Native/WindowsSignaler.cs (namespace CliWrap.Native)
  • CliWrap.Signaler/Utils/NativeMethods.cs → CliWrap.Signaler/Native/NativeMethods.cs (namespace CliWrap.Signaler.Native)

Simplified using PowerKit extensions

  • ArgumentsBuilder.cs: space-separator guard (if (_buffer.Length > 0) _buffer.Append(' ')) → _buffer.AppendIfNotEmpty(' ') (StringBuilderExtensions)
  • Command.Execution.cs: nested !string.IsNullOrWhiteSpace(...) checks → ?.NullIfWhiteSpace() is { } pattern (FunctionalExtensions)

Package updates

Package Before After
PowerKit — 0.0.0-a.8
PolyShim 2.7.0 2.11.0-a.1

Retained (no PowerKit equivalent)

  • Utils/Extensions/AssertionExtensions.cs (test-specific)
  • Utils/Extensions/EnvironmentExtensions.cs (test-specific, SetTempEnvironmentVariable / ExtendPath)
  • All other Utils/ types (Channel, SimplexStream, ProcessEx, etc.)

@Tyrrrz

Tyrrrz commented Apr 17, 2026

Copy link
Copy Markdown
Owner

@copilot also move NativeMethods out of Utils/ into Native/

Agent-Logs-Url: https://github.com/Tyrrrz/CliWrap/sessions/bf2a3dbf-2258-4fad-b411-807ac4ebef47

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot also move NativeMethods out of Utils/ into Native/

Done in c06ac6c — NativeMethods.cs is now at Native/NativeMethods.cs with namespace CliWrap.Native, and ProcessEx.cs updated accordingly.

@Tyrrrz

Tyrrrz commented Apr 17, 2026

Copy link
Copy Markdown
Owner

@copilot there are utilites that can be replaced in other projects

Copilot AI requested a review from Tyrrrz April 17, 2026 12:11
@Tyrrrz

Tyrrrz commented Apr 17, 2026

Copy link
Copy Markdown
Owner

@copilot also move NativeMethods out of Utils/ into Native/

Done in c06ac6c — NativeMethods.cs is now at Native/NativeMethods.cs with namespace CliWrap.Native, and ProcessEx.cs updated accordingly.

You forgot the signaler project @copilot

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot there are utilites that can be replaced in other projects

Done in bb415cf — CliWrap.Signaler/Utils/NativeMethods.cs is now at CliWrap.Signaler/Native/NativeMethods.cs (namespace CliWrap.Signaler.Native), matching the same reorganization applied to the main project. The now-empty Utils/ folder was also removed.

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot also move NativeMethods out of Utils/ into Native/

Done in c06ac6c — NativeMethods.cs is no...

Already addressed in bb415cf — CliWrap.Signaler/Utils/NativeMethods.cs is now at CliWrap.Signaler/Native/NativeMethods.cs with namespace CliWrap.Signaler.Native.

@codecov

codecov Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.64%. Comparing base (153e0a1) to head (bb415cf).

Additional details and impacted files
@@            Coverage Diff             @@
##            prime     #327      +/-   ##
==========================================
+ Coverage   94.51%   94.64%   +0.13%     
==========================================
  Files          34       29       -5     
  Lines        1112     1083      -29     
  Branches       72       67       -5     
==========================================
- Hits         1051     1025      -26     
+ Misses         40       38       -2     
+ Partials       21       20       -1     

☔ 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

Tyrrrz commented Apr 17, 2026

Copy link
Copy Markdown
Owner

@copilot check other projects too, not just CliWrap

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot check other projects too, not just CliWrap

Done in dc7a1c6 — CliWrap.Tests now uses PowerKit equivalents:

  • Utils/Extensions/ProcessExtensions.cs removed (PowerKit's ProcessExtensions is identical)
  • Utils/TempDir.cs removed → PowerKit.TempDirectory
  • Utils/TempFile.cs removed → PowerKit.TempFile
  • EnvironmentExtensions.cs updated to use PowerKit.Disposable instead of System.Reactive.Disposables.Disposable

No changes needed for CliWrap.Signaler, CliWrap.Tests.Dummy, or CliWrap.Benchmarks — they have no replaceable utilities.

@Tyrrrz

Tyrrrz commented Apr 18, 2026

Copy link
Copy Markdown
Owner

@copilot please update PowerKit (and PolyShim if build fails) to latest pre-release. See if the introduced utilites/extensions can be useful in replacing more of our code.

…ble, SynchronizedObserver, AsyncDisposableExtensions, StringExtensions

Agent-Logs-Url: https://github.com/Tyrrrz/CliWrap/sessions/5ba3d2c4-8070-41a4-a0bf-e03e8f0f1eb1

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>

Copilot AI commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please update PowerKit (and PolyShim if build fails) to latest pre-release. See if the introduced utilites/extensions can be useful in replacing more of our code.

Done in 3aeff6b — upgraded to PowerKit 0.0.0-a.7 and PolyShim 2.11.0-a.1. The new PowerKit release adds Observable, SynchronizedObserver, AsyncDisposableExtensions, and StringExtensions (including ToSecureString()), so all four were removed from the project.

One note: PowerKit a.7's ClientDelegatingHandler.cs has a doc comment placed after an attribute, which triggers CS1587. Since the project has TreatWarningsAsErrors=true, I added <WarningsNotAsErrors>CS1587</WarningsNotAsErrors> to Directory.Build.props to keep it a warning rather than a build error.

hawkeye116477 added a commit to hawkeye116477/CliWrap-net462 that referenced this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants