ForNeVeR / TruePath

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

Separate NuGet for IO methods (`TruePath.Extensions.IO`) #86

Open ForNeVeR opened 2 months ago

ForNeVeR commented 2 months ago

Slowly but surely, constant mentioning of .Value when performing file IO becomes a nuisance. One example I had just now:

let ReadValue (filePath: LocalPath) (key: string): Task<string> = task {
    let! toml = File.ReadAllTextAsync filePath.Value

Our path types lack implicit conversion to string (for a reason!), and thus you have to call .ToString() or .Value to convert them before passing to the system file-related API.

I propose we introduce a new package, say TruePath.Extensions.IO to provide some extension methods over our paths, so that this example would look like

let ReadValue (filePath: LocalPath) (key: string): Task<string> = task {
    let! toml = filePath.ReadAllTextAsync()