Skip to content
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

FileSystem property of DirectoryInfo is not what it seems #1173

Open
montoner0 opened this issue Dec 10, 2024 · 3 comments
Open

FileSystem property of DirectoryInfo is not what it seems #1173

montoner0 opened this issue Dec 10, 2024 · 3 comments
Labels
state: needs discussion Issues that need further discussion type: enhancement Issues that propose new functionality

Comments

@montoner0
Copy link

Is your feature request related to a problem? Please describe.
On multiple occasions I've misinterpret the DirectoryInfo.FileSystem property as related to this exact DirectoryInfo object which isn't true at all.

Describe the solution you'd like
It would be nice to have some clear statement in the description that they aren't related (yes, I know that's derived from IFileSystemInfo interface but still). Something like "The property isn't related to its parent object".

@montoner0 montoner0 added state: needs discussion Issues that need further discussion type: enhancement Issues that propose new functionality labels Dec 10, 2024
@vbreuss
Copy link
Member

vbreuss commented Dec 10, 2024

I am not sure I get what you mean. The description of the FileSystem property is:

/// <summary>
/// Exposes the underlying filesystem implementation. This is useful for implementing extension methods.
/// </summary>

What is your interpretation of the file system being "related to the parent object"?

@montoner0
Copy link
Author

I mean the property could be considered as acting within a scope of the object it belongs.
As if DirectoryInfo.FileSystem.File.Create(filename) would create a file in the directory of DirectoryInfo.

@vbreuss
Copy link
Member

vbreuss commented Dec 12, 2024

Ah, I see your point. You would expect the current directory to be changed, when you access the file system from a IDirectoryInfo instance.
Unfortunately, this is not really possible, because we always return the same instance and changing the (global) current directory on accessing a property would lead to very confusing behavior (especially, if the accessing of the property is hidden in e.g. an extension method).

Do you have a suggestion on how to improve the documentation to make this more clear?
Feel free to create a pull request...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs discussion Issues that need further discussion type: enhancement Issues that propose new functionality
Projects
None yet
Development

No branches or pull requests

2 participants