Skip to content

Conversation

@JoshuaStone9
Copy link

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 :)

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 :)
@ForNeVeR ForNeVeR requested a review from Copilot November 10, 2025 13:24
@ForNeVeR ForNeVeR self-assigned this Nov 10, 2025
Copy link

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

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 AbsolutePath readonly struct with a Value property 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; }

Copy link

Copilot AI Nov 10, 2025

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.

Suggested change
public AbsolutePath(string value)
{
Value = value;
}

Copilot uses AI. Check for mistakes.
Comment on lines +197 to +199
public bool Exists() =>
File.Exists(Value) || Directory.Exists(Value);

Copy link

Copilot AI Nov 10, 2025

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.

Suggested change
public bool Exists() =>
File.Exists(Value) || Directory.Exists(Value);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants