ForNeVeR / TruePath

File path abstraction library for .NET.
https://www.nuget.org/packages/TruePath
MIT License
39 stars 4 forks source link

Add file and directory path separate abstractions #58

Open rodion-m opened 1 month ago

rodion-m commented 1 month ago

For example, https://github.com/ndepend/NDepend.Path has IAbsoluteFilePath, IAbsoluteDirectoryPath, IRelativeDirectoryPath and IRelativeFilePath. It'd be great to see such abstractions in TruePath too.

ForNeVeR commented 1 month ago

I believe this deserves more discussion.

My current view on the library is that it should grant the compile-time safety for the provided entities.

While a path could be easily classified as absolute or relative in compile time, and won't ever change its classification, it could easily be changed from a file to a directory (or even to not being existent) in runtime.

I have a vague feeling that this kind of classification is better handled by runtime attributes (such as — methods, properties etc.) than compile-time types.

But I understand the need.

Perhaps we can implement wrappers around our current paths that will additionally check whether they are files or directories at some moment in runtime?

What should be the operational model of these types? NDepend.Path documentation shows allowed operations for IAbsoluteFilePath but not IRelativeFilePath. What's the practical difference between file and directory path, from the library standpoint?