Add Directory.CreateForFile extension method#72
Merged
Conversation
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/1af636ec-a6c0-4884-91e3-faa6ff0856be Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
Tyrrrz
April 19, 2026 10:24
View session
Tyrrrz
reviewed
Apr 19, 2026
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/af0aef58-4e32-4e84-afd9-9f56d54656ef Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Directory.CreateForFile(string filePath) extension to ensure the parent directory tree exists for a given file path, aligning with PowerKit’s IO helper extensions and enabling safer “create dirs then write file” workflows.
Changes:
- Added
Directory.CreateForFile(string filePath)that creates the directory component of a file path (no-op if none). - Added tests intended to cover flat and nested file paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| PowerKit/Extensions/DirectoryExtensions.cs | Introduces CreateForFile() extension that derives the directory via Path.GetDirectoryName() and creates it. |
| PowerKit.Tests/Extensions/DirectoryExtensionsTests.cs | Adds tests for CreateForFile() behavior (currently one test doesn’t validate the intended behavior). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## prime #72 +/- ##
==========================================
+ Coverage 93.85% 93.88% +0.02%
==========================================
Files 128 128
Lines 2524 2534 +10
Branches 200 201 +1
==========================================
+ Hits 2369 2379 +10
Misses 112 112
Partials 43 43 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Tyrrrz
approved these changes
Apr 19, 2026
This was referenced May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a static extension method on
Directorythat creates the directory tree needed for a given file path.Changes
DirectoryExtensions.cs— newDirectory.CreateForFile(string filePath)method; extracts the directory component viaPath.GetDirectoryNameand delegates toDirectory.CreateDirectory, creating all intermediate directories. No-ops if the path has no directory component.DirectoryExtensionsTests.cs— two new tests covering a flat path and a deeply nested path.Usage