Fable: Support System.IO.Path

Created on 30 Jan 2021  路  3Comments  路  Source: fable-compiler/Fable

Description

It might be nice to have a replacement implementation of System.IO.Path in Fable. I've written a pretty robust one over at Fable.System.IO. Perhaps a merger of this into core Fable would be a net good?

I thought I've already asked this somewhere, but I can't find it anymore. The reason it's already its own library is because I figured @alfonsogarciacaro would take the viewpoint that it's better in general to keep BCL API implementations out of Fable itself and in separate libraries to reduce maintainer overhead of Fable itself -- at which point, the question becomes whether or not this is worth that cost. Might be, might not be, but I figured I'd bring it up!

The one thing that would make this tricky is the fact that Fable.System.IO uses a platform detector (currently platform-detect from npm; but in the process of switching over to Shmew's F#-only Fable.Extras). So if Fable were to properly absorb this code, it would have to either similarly take some kind of dependency (or inline) on a platform detector, or it would just choose which environment's behavior to emulate (Windows vs Unix paths).

FWIW, I have complete unit test coverage here.

Most helpful comment

Hi @jwosty! This is a great work you've done with Fable.System.IO 馃憦馃憦馃憦 I understand your desire to see this integrated into Fable, but I'm still very careful in trying to shim more .NET APIs. Path is useful, but I assume when adding any support for System.IO people will try to use File as well. Javascript can run in multiple environments: browser, nodejs, mobile... and trying to support File I/O in all of these is too big an undertake (for me). We already have trouble with binary serialization because btoa is not supported in Node :/

Also, fable-library doesn't have dependencies, so we would have to include platform-detect in our codebase. We've already done something like that for decimals and longs, but besides this causing trouble with bundle sizes (as in https://github.com/thoth-org/Thoth.Json/pull/96 which took me a long time to realize) we're actually trying to remove this external js code and go for a full f# fable-library.

Fable.System.IO is fantastic and I think this is the way to go for .NET developers who want yo use familiar APIs in a JS environment: a library that is similar to what they're used to, but gives immediate hints in the IDE about what is supported and the platform differences.

All 3 comments

Hi @jwosty! This is a great work you've done with Fable.System.IO 馃憦馃憦馃憦 I understand your desire to see this integrated into Fable, but I'm still very careful in trying to shim more .NET APIs. Path is useful, but I assume when adding any support for System.IO people will try to use File as well. Javascript can run in multiple environments: browser, nodejs, mobile... and trying to support File I/O in all of these is too big an undertake (for me). We already have trouble with binary serialization because btoa is not supported in Node :/

Also, fable-library doesn't have dependencies, so we would have to include platform-detect in our codebase. We've already done something like that for decimals and longs, but besides this causing trouble with bundle sizes (as in https://github.com/thoth-org/Thoth.Json/pull/96 which took me a long time to realize) we're actually trying to remove this external js code and go for a full f# fable-library.

Fable.System.IO is fantastic and I think this is the way to go for .NET developers who want yo use familiar APIs in a JS environment: a library that is similar to what they're used to, but gives immediate hints in the IDE about what is supported and the platform differences.

Closing as we've Fable.System.IO as a great alternative to trying to add more (imperfect) BCL replacements. Thanks again for this @jwosty!

Sure thing; I can definitely understand this reasoning!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MangelMaxime picture MangelMaxime  路  3Comments

forki picture forki  路  3Comments

et1975 picture et1975  路  3Comments

et1975 picture et1975  路  3Comments

alfonsogarciacaro picture alfonsogarciacaro  路  3Comments