Repository navigation
Add preCreate parameter to TempFile.Create() and TempDirectory.Create() - #35
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/98d7c4ed-60a1-49e3-be5c-abd7e8d3fcda Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Owner
|
Let's do the same with TempDirectory @copilot |
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/2ef08c74-5a85-4ba6-8453-8fcba2b3b64d Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Contributor
Author
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an option to TempFile.Create() to return a unique temp file path without creating the file on disk, supporting scenarios where callers want a path reservation without filesystem writes.
Changes:
- Extended
TempFile.Create()with an optionalpreCreateparameter (defaulttrue) to control whether the file is created. - Added a unit test verifying the
preCreate: falsebehavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| PowerKit/TempFile.cs | Adds preCreate parameter and conditional file creation logic in TempFile.Create(). |
| PowerKit.Tests/TempFileTests.cs | Adds test coverage for the new preCreate: false behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot
AI
changed the title
Add
Add Apr 15, 2026
preCreate parameter to TempFile.Create()preCreate parameter to TempFile.Create() and TempDirectory.Create()
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/a6da0531-ffae-41c9-a3eb-f5e9e74aa910 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Tyrrrz
reviewed
Apr 15, 2026
Tyrrrz
reviewed
Apr 15, 2026
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/43b3adf2-1f1d-462b-a46f-81cf7cf51924 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/7ee14a79-a135-4a33-848c-eac326119211 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Tyrrrz
reviewed
Apr 15, 2026
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/ad650325-f885-4742-ab4b-eb64d70b25a5 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/ca3f2bf9-95bf-46f4-930e-629592925d0a Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…try/catch Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/811e85a4-1a03-497a-afbf-a901fb9ce080 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Tyrrrz
approved these changes
Apr 15, 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.
TempFile.Create()andTempDirectory.Create()previously always created the file/directory on disk. This adds apreCreateparameter to both so callers can obtain a unique temp path without touching the filesystem.TempFile.cs: Addedbool preCreate = truetoCreate(). Whenfalse, skips file creation — only the path is generated. Whentrue, usesFileStreamwithFileMode.CreateNewto avoid overwriting, retries with a fresh GUID on path collision (up to 20 attempts), and throwsInvalidOperationExceptionif all attempts are exhausted.TempFileTests.cs: AddedCreate_WithoutPreCreate_Testcovering thepreCreate: falsecase.TempDirectory.cs: Addedbool preCreate = truetoCreate(). Whenfalse, skips directory creation — only the path is generated. Whentrue, retries with a fresh GUID if the path already exists (up to 20 attempts), and throwsInvalidOperationExceptionif all attempts are exhausted.TempDirectoryTests.cs: AddedCreate_WithoutPreCreate_Testcovering thepreCreate: falsecase.