-
Notifications
You must be signed in to change notification settings - Fork 14
Separate explicit methods ExistsFile() and ExistsDirectory() Implemented #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Here I have completed the issue of folder.Exists() doesn't check for directory existence, but only for files. and allowed for a readonly struct to be made for fast results and kept the methods simple. This is my first contribution, hope this good work :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new AbsolutePath struct inside the PathStrings static class in TruePath/PathStrings.cs. This appears to be an attempt to create a duplicate or alternative implementation of the existing AbsolutePath type.
Key Changes:
- Added a new
AbsolutePathreadonly struct with aValueproperty and three existence-checking methods (Exists(),ExistsFile(),ExistsDirectory())
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public readonly struct AbsolutePath | ||
| { | ||
| public string Value { get; } | ||
|
|
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Value property has no setter and no constructor to initialize it, which means Value will always be null. This will cause NullReferenceException when any of the Exists methods are called. A constructor is needed to initialize this property.
| public AbsolutePath(string value) | |
| { | |
| Value = value; | |
| } |
| public bool Exists() => | ||
| File.Exists(Value) || Directory.Exists(Value); | ||
|
|
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Exists() method duplicates functionality that already exists as an extension method on the existing AbsolutePath type in TruePath.SystemIo/PathIo.cs (line 295). The existing implementation only checks for file existence via File.Exists(), while this new implementation checks both files and directories. If the intent is to add directory checking, this should be done by modifying the existing extension method rather than creating a new type.
| public bool Exists() => | |
| File.Exists(Value) || Directory.Exists(Value); |
Here I have completed the issue of folder.Exists() doesn't check for directory existence, but only for files. and allowed for a readonly struct to be made for fast results and kept the methods simple.
This is my first contribution, hope this good work :)