fsprojects / FSharp.Data

F# Data: Library for Data Access
https://fsprojects.github.io/FSharp.Data
Other
815 stars 287 forks source link

Relative paths not working in XS/Mac #160

Closed rojepp closed 11 years ago

rojepp commented 11 years ago

I'm trying to specify a file to use with the Json TP, and it is not working in Xamarin Studio on Mac. This works on Windows/VS2012:

type GeoResults = JsonProvider<"addressresults.txt">

On Mac, I get an error:

/Users/robert/geofindervgr/GeoFinderVGR/Program.fs(19,19): Error FS3033: The type 
provider 'ProviderImplementation.JsonProvider' reported an error: 
Specified argument is neither a file, nor well-formed JSON: 
Could not find file "/addressresults.txt". (FS3033) (GeoFinderVGR)

Absolute paths work fine, but is obviously not an option:

type GeoResults = JsonProvider<"""/Users/robert/geofindervgr/GeoFinderVGR/addressresults.txt""">

I'm guessing this bug applies to all TP's in FSharp.Data?

rojepp commented 11 years ago

Debugging it, I see that cfg.ResolutionFolder is set to '/' when building from Xamarin Studio. Hard-coding it to the current project works:

[<TypeProvider>]
type public JsonProvider(cfg:TypeProviderConfig) as this =
  inherit TypeProviderForNamespaces()

  do cfg.ResolutionFolder <- "/Users/robert/geofindervgr/GeoFinderVGR"

Obviously, this is not a bug in FSharp.Data, and should affect all Type Providers that read local files. Possibly a bug in the language binding, ie. something it should be doing that it's not? Maybe @dsyme could help locate it?

rojepp commented 11 years ago

Closing, raised an issue in fsharpbinding instead, as this has nothing to do with FSharp.Data.

ovatsus commented 11 years ago

Are you sure that cfg.ResolutionFolder that is wrong? That value is set by the compiler when invoking the type provider design time assembly, so if it comes wrong, the bug is in the compiler itself and not the binding

rojepp commented 11 years ago

Yup, I'm sure it's wrong, It is set to '/' when compiling. Oddly, intellisense and error check manages to compile the file. See more at the fsharpbinding bug: https://github.com/fsharp/fsharpbinding/issues/161