Skip to content

Add PowerKit, update PolyShim to 2.10.1, remove hand-written utility equivalents#185

Merged
Tyrrrz merged 4 commits intoprimefrom
copilot/add-powerkit-replace-utilities
Apr 17, 2026
Merged

Add PowerKit, update PolyShim to 2.10.1, remove hand-written utility equivalents#185
Tyrrrz merged 4 commits intoprimefrom
copilot/add-powerkit-replace-utilities

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Integrates PowerKit (source-only) as a shared utilities library, replaces hand-written code it now covers, and bumps PolyShim from 2.7.0 → 2.10.1.

Deleted files (fully covered by PowerKit)

  • CliFx/Utils/Disposable.csPowerKit.Disposable
  • CliFx/Utils/NoPreambleEncoding.cs → internal to PowerKit's EncodingExtensions
  • CliFx/Utils/Extensions/EncodingExtensions.csPowerKit.Extensions.EncodingExtensions
  • CliFx/Utils/Extensions/PrimitiveExtensions.csPowerKit.Extensions.BoolExtensions (ParseOrNull)
  • CliFx/Utils/Extensions/CollectionExtensions.csPowerKit.Extensions.CollectionExtensions (RemoveRange) + PowerKit.Extensions.DictionaryExtensions (ToDictionary)
  • CliFx/Utils/Extensions/StringExtensions.csPowerKit.Extensions.CharExtensions (Repeat); AsString inlined as char.ToString()
  • CliFx/Utils/Extensions/VersionExtensions.csPowerKit.Extensions.VersionExtensions (ToSemanticString)
  • CliFx.Generators/Utils/Extensions/CollectionExtensions.csPowerKit.Extensions.EnumerableExtensions
  • CliFx.Generators/Utils/Extensions/StringExtensions.csPowerKit.Extensions (ToKebabCase, NullIfWhiteSpace)
  • CliFx.Tests/Utils/Extensions/CollectionExtensions.csPowerKit.Extensions.EnumerableExtensions

Trimmed files (partial overlap)

  • CollectionExtensions.cs (CliFx): removed WhereNotNull / WhereNotNullOrWhiteSpace (covered earlier); RemoveRange and ToDictionary now fully covered by PowerKit 0.0.0-a.6 → file deleted
  • StringExtensions.cs (CliFx): removed NullIfWhiteSpace (covered earlier); Repeat now covered by PowerKit 0.0.0-a.6 → file deleted

PolyShim 2.10.1

PolyShim 2.10.1 fixes the ManualResetValueTaskSourceCore<T> detection bug on netstandard2.0 that was present in 2.10.0 — the incorrect FEATURE_VALUETASK_SOURCES_MANUALRESET constant was removed entirely from its feature-detection targets. No Directory.Build.targets workaround is needed.

@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 17, 2026

but the netstandard2.0 flavour of that package is a type-forwarding stub that doesn't contain it.

@copilot what do you mean by that?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 17, 2026

but the netstandard2.0 flavour of that package is a type-forwarding stub that doesn't contain it.

@copilot what do you mean by that?

Sorry, that description was imprecise. The System.Threading.Tasks.Extensions netstandard2.0 DLL is not a type-forwarding stub — it's a real ~28 KB assembly that contains IValueTaskSource<T>, ValueTaskSourceStatus, ValueTaskSourceOnCompletedFlags, and ValueTask<T>. The more accurate statement is that ManualResetValueTaskSourceCore<T> is simply absent from the netstandard2.0 flavor of the package — it was only introduced in .NET Core 2.1 / netstandard2.1.

PolyShim 2.10.0 detects System.Threading.Tasks.Extensions in the reference path and, per its targets, marks FEATURE_VALUETASK_SOURCES_MANUALRESET as available for any netstandard2.0+ project that references the package — even though the netstandard2.0 DLL doesn't actually contain that type. The Directory.Build.targets fix clears the constant afterwards so PolyShim still emits its own polyfill for the missing struct.

Copilot AI requested a review from Tyrrrz April 17, 2026 06:27
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 17, 2026

Please update PowerKit, we should be able to replace even more extensions now. @copilot

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 17, 2026

Please update PowerKit, we should be able to replace even more extensions now. @copilot

Done in fa635bd. Updated PowerKit to 0.0.0-a.6, which now provides CharExtensions (Repeat), CollectionExtensions (RemoveRange), DictionaryExtensions (ToDictionary), and VersionExtensions (ToSemanticString). Deleted the three remaining hand-written files (CollectionExtensions.cs, StringExtensions.cs, VersionExtensions.cs) and replaced the single AsString() call in ParsedCommandLine.cs with identifier.ToString() (since AsString was dropped from PowerKit). All 121 tests pass.

@Tyrrrz Tyrrrz marked this pull request as ready for review April 17, 2026 08:51
Copilot AI review requested due to automatic review settings April 17, 2026 08:51
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.92%. Comparing base (ee3fb97) to head (b51a875).
⚠️ Report is 1 commits behind head on prime.

Additional details and impacted files
@@            Coverage Diff             @@
##            prime     #185      +/-   ##
==========================================
+ Coverage   91.78%   91.92%   +0.14%     
==========================================
  Files          74       65       -9     
  Lines        2374     2329      -45     
  Branches      300      282      -18     
==========================================
- Hits         2179     2141      -38     
+ Misses        134      129       -5     
+ Partials       61       59       -2     

☔ 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.

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

Integrates the source-only PowerKit utilities into CliFx to replace local utility implementations, upgrades PolyShim to 2.10.0, and adds an MSBuild workaround to ensure correct PolyShim feature detection on netstandard2.0.

Changes:

  • Add PowerKit dependency and migrate call sites from CliFx.Utils.* helpers to PowerKit equivalents.
  • Remove now-redundant hand-written utility/extension files in CliFx, generators, and tests.
  • Bump PolyShim to 2.10.0 and add Directory.Build.targets to clear an incorrectly detected feature constant on netstandard2.0.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Directory.Packages.props Bumps PolyShim and adds centralized PowerKit version.
Directory.Build.targets Adds netstandard2.0 PolyShim feature-detection workaround by modifying DefineConstants.
CliFx/CliFx.csproj Adds PowerKit reference to main library project.
CliFx.Tests/CliFx.Tests.csproj Adds PowerKit reference for tests.
CliFx.Generators/CliFx.Generators.csproj Adds PowerKit reference for source generator project.
CliFx/CommandLineApplication.cs Switches env-var bool parsing to PowerKit (ParseOrNull).
CliFx/CommandLineApplicationBuilder.cs Switches version formatting extension to PowerKit (ToSemanticString).
CliFx/Infrastructure/ConsoleWriter.cs Switches encoding helper (WithoutPreamble) to PowerKit.
CliFx/Infrastructure/ConsoleExtensions.cs Switches Disposable helper to PowerKit.
CliFx/Binding/CommandRootDescriptor.cs Switches collection/string helpers (WhereNotNullOrWhiteSpace, RemoveRange) to PowerKit.
CliFx/Activation/CommandActivator.cs Switches collection helper (RemoveRange) to PowerKit.
CliFx/Parsing/ParsedCommandLine.cs Inlines charstring conversion (ToString) after removing local AsString.
CliFx/Utils/StackTraces/StackFrame.cs Switches string helper (NullIfWhiteSpace) to PowerKit.
CliFx.Tests/Utils/CommandCompiler.cs Switches WhereNotNull helper to PowerKit.
CliFx.Generators/* (Binding/Emitters/Generator) Switches WhereNotNull, NullIfWhiteSpace, ToKebabCase helpers to PowerKit.
CliFx/Utils/* deleted utility files Removes local equivalents now covered by PowerKit (Disposable, encoding wrapper, extension helpers, etc.).
CliFx.Generators/Utils/Extensions/* deleted Removes generator-local equivalents now covered by PowerKit.
CliFx.Tests/Utils/Extensions/* deleted Removes test-local equivalents now covered by PowerKit.

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

Comment thread Directory.Build.targets Outdated
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 17, 2026

@copilot Update PolyShim and see if the ValueTask-related issue is solved upstream.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 17, 2026

@copilot Update PolyShim and see if the ValueTask-related issue is solved upstream.

Done in b51a875. PolyShim 2.10.1 includes the fix ("Fix ManualResetValueTaskSourceCore polyfill missing on netstandard2.0" — the FEATURE_VALUETASK_SOURCES_MANUALRESET constant was removed entirely from its detection targets). Updated PolyShim to 2.10.1 and deleted Directory.Build.targets — the workaround is no longer needed. All 121 tests pass.

Copilot AI changed the title Add PowerKit, update PolyShim to 2.10.0, remove hand-written utility equivalents Add PowerKit, update PolyShim to 2.10.1, remove hand-written utility equivalents Apr 17, 2026
@Tyrrrz Tyrrrz merged commit 4531d02 into prime Apr 17, 2026
7 checks passed
@Tyrrrz Tyrrrz deleted the copilot/add-powerkit-replace-utilities branch April 17, 2026 10:11
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