Skip to content

Create PowerKit: source-only NuGet package of shared utility extensions#1

Merged
Tyrrrz merged 43 commits intoprimefrom
copilot/consolidate-utils-and-extensions
Apr 12, 2026
Merged

Create PowerKit: source-only NuGet package of shared utility extensions#1
Tyrrrz merged 43 commits intoprimefrom
copilot/consolidate-utils-and-extensions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

  • Expand InvalidFileNameChars to include ASCII control characters 0x01-0x1F
  • Add braces to foreach blocks
  • Rename char variable c to ch in PathExtensions.cs and StringExtensions.cs
  • Use pattern matching and arrow-bodied method in AggregateExceptionExtensions
  • Add braces to foreach body in AsyncEnumerableExtensions (SelectManyAsync)
  • Add GetInvalidFileNameChars and GetInvalidPathChars with crossPlatform parameter, update EscapeFileName
  • Add SubstringUntilLast and SubstringAfterLast to StringExtensions
  • Update PR body with summary of everything done
  • Initialize CrossPlatformInvalidPathChars from CrossPlatformInvalidFileNameChars to reduce duplication
Original prompt

Can you search through the following projects:

Look at what utilites/extensions these projects define (conventionally in the Utils dir/namespace).

Consolidate them into a single codebase to share between those projects.

To package it, create a source-only package similar to this one: https://github.com/Tyrrrz/PolyShim

Replicate PolyShim's approach, but adopt a simpler structure since we're not building a polyfill package. Copy the license file, gitignore, and other peripheral files.

Use the new slnx format for the solution file (run dotnet sln migrate to convert).

@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 7, 2026
…utility extensions

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/43c1b0cc-139f-46f8-9717-63e43e341fc1

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copilot AI changed the title [WIP] Consolidate utilities and extensions into a shared codebase Create PowerKit: source-only NuGet package of shared BCL-only utility extensions Apr 7, 2026
Copilot AI requested a review from Tyrrrz April 7, 2026 16:20
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 7, 2026

@copilot remove the Utils namespace/dir and move everything one level up

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 7, 2026

@copilot remove the Utils namespace/dir and move everything one level up

Done in ad3489c. Utils/ directory removed — Disposable.cs is now directly under PowerKit/ (namespace PowerKit) and all extension files are under PowerKit/Extensions/ (namespace PowerKit.Extensions).

@Tyrrrz Tyrrrz marked this pull request as ready for review April 7, 2026 16:32
Copilot AI review requested due to automatic review settings April 7, 2026 16:32
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

Introduces PowerKit, a source-only NuGet package that consolidates shared, BCL-only utility and extension helpers for reuse across Tyrrrz projects (PolyShim-style packaging).

Changes:

  • Adds a source-only packaging setup (PowerKit.csproj + build/PowerKit.props) that forces LangVersion=preview for consumers.
  • Implements a set of internal utility extensions (async enumerable helpers, string/stream/path helpers, etc.) plus a small Disposable helper.
  • Adds repo-level build/config scaffolding (solution, SDK pinning, NuGet config, license, gitignore, shared props).

Reviewed changes

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

Show a summary per file
File Description
PowerKit/PowerKit.props MSBuild props for consumers (sets LangVersion=preview).
PowerKit/PowerKit.csproj Source-only NuGet packing configuration (contentFiles + build props).
PowerKit/Disposable.cs Disposable factory helpers (Null, Create, Merge).
PowerKit/Extensions/AsyncCollectionExtensions.cs Async enumerable helpers (TakeAsync, ToListAsync, awaiter).
PowerKit/Extensions/CollectionExtensions.cs Enumerable helpers (null filtering, singleton, nullable element access).
PowerKit/Extensions/ExceptionExtensions.cs Exception traversal helpers.
PowerKit/Extensions/GenericExtensions.cs Functional helpers (Pipe, NullIf*).
PowerKit/Extensions/PathExtensions.cs Cross-platform filename escaping helper.
PowerKit/Extensions/StreamExtensions.cs Stream copy helpers (auto-flush, progress reporting).
PowerKit/Extensions/StringExtensions.cs String + StringBuilder helper extensions.
PowerKit/Extensions/TextReaderExtensions.cs Async line enumeration for TextReader.
PowerKit/Extensions/TimeSpanExtensions.cs TimeSpan.Clamp.
PowerKit.slnx Solution file in slnx format.
NuGet.config Defines NuGet.org as the only package source + default push source.
License.txt MIT license file.
global.json Pins .NET SDK version.
Directory.Build.props Shared build/package metadata defaults.
.gitignore Standard ignores for VS/IDE/build outputs.

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

Comment thread PowerKit/Extensions/CollectionExtensions.cs Outdated
Comment thread PowerKit/Extensions/AsyncEnumerableExtensions.cs
Comment thread PowerKit/Extensions/AsyncEnumerableExtensions.cs Outdated
Comment thread PowerKit/Extensions/AsyncEnumerableExtensions.cs Outdated
Comment thread PowerKit/Extensions/AsyncEnumerableExtensions.cs Outdated
Comment thread PowerKit/Extensions/StreamExtensions.cs
Comment thread PowerKit/Extensions/PathExtensions.cs Outdated
Comment thread PowerKit/Extensions/PathExtensions.cs Outdated
Copy link
Copy Markdown
Owner

@Tyrrrz Tyrrrz left a comment

Choose a reason for hiding this comment

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

Also rename all extension classes to {ReceiverType}Extensions. Split classes that affect multiple types into separate files.

@copilot

Comment thread PowerKit/Extensions/ExceptionExtensions.cs Outdated
Comment thread PowerKit/Extensions/GenericExtensions.cs Outdated
Comment thread PowerKit/Extensions/PathExtensions.cs Outdated
Comment thread PowerKit/PowerKit.props Outdated
Comment thread PowerKit/PowerKit.csproj Outdated
Comment thread Directory.Build.props Outdated
Comment thread PowerKit.slnx
Tyrrrz and others added 2 commits April 7, 2026 19:41
Updated copyright year in the License file.
…tandard2.0, remove props

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/7af97092-2f8d-463c-8357-7b2ac9afa654

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

Copilot AI commented Apr 7, 2026

Also rename all extension classes to {ReceiverType}Extensions. Split classes that affect multiple types into separate files.

@copilot

Done in 8c4b9aa. All classes renamed to {ReceiverType}Extensions and multi-receiver classes split into separate files:

  • AsyncCollectionExtensionsAsyncEnumerableExtensions
  • CollectionExtensionsEnumerableExtensions + ObjectExtensions
  • ExceptionExtensionsExceptionExtensions + AggregateExceptionExtensions
  • GenericExtensionsFunctionalExtensions
  • StringExtensionsStringExtensions + StringBuilderExtensions

…ait, CanSeek, fileName param

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/f217b614-b393-402a-857b-37113c1e00d1

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

Tyrrrz commented Apr 7, 2026

@copilot can you also add tests?

Comment thread PowerKit/Extensions/StreamExtensions.cs Outdated
Copilot AI and others added 2 commits April 11, 2026 18:38
Comment thread PowerKit.Tests/StreamExtensionsTests.cs Outdated
…yToAsync_Progress_Test)

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/f8dd53be-d7fe-4818-a11e-69427b83c252

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
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 33 out of 34 changed files in this pull request and generated 8 comments.


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

Comment thread PowerKit/Disposable.cs
Comment thread PowerKit/Extensions/StreamExtensions.cs Outdated
Comment thread PowerKit/Extensions/ComparableExtensions.cs
Comment thread PowerKit/Extensions/AsyncEnumerableExtensions.cs Outdated
Comment thread PowerKit/Extensions/AsyncEnumerableExtensions.cs
Comment thread PowerKit/Extensions/PathExtensions.cs Outdated
Comment thread PowerKit/Extensions/AggregateExceptionExtensions.cs Outdated
Comment thread PowerKit/PowerKit.csproj
Tyrrrz and others added 2 commits April 11, 2026 22:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 11, 2026

@copilot #1 (comment) please address this

Copilot AI and others added 2 commits April 12, 2026 09:44
…0x1F and add braces to foreach

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/a2731348-f326-4da6-af04-9d444f6f2efd

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

Tyrrrz commented Apr 12, 2026

@copilot update the PR body with the summary of everything done

Comment thread PowerKit/Extensions/AggregateExceptionExtensions.cs Outdated
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 33 out of 34 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 PowerKit/Extensions/TextReaderExtensions.cs
Comment thread PowerKit/Extensions/AsyncEnumerableExtensions.cs Outdated
Comment thread PowerKit/Extensions/AsyncEnumerableExtensions.cs
Comment thread PowerKit/Extensions/PathExtensions.cs
Comment thread PowerKit/Extensions/StringExtensions.cs
Copilot AI and others added 6 commits April 12, 2026 10:07
…ensions, braces in AsyncEnumerableExtensions, add SubstringUntilLast/SubstringAfterLast, refactor PathExtensions with GetInvalidFileNameChars/GetInvalidPathChars/crossPlatform param

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/f860d5c2-2b94-48ae-a785-334b01ce9d09

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…eChars to reduce duplication

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/56e3e0eb-b42d-49cc-a361-0b7b771dd982

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
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