FSharp.Data icon indicating copy to clipboard operation
FSharp.Data copied to clipboard

JsonProvider doesn't refresh the source when using a web document

Open fischgeek opened this issue 4 years ago • 1 comments

Issue

When using a JsonProvider source from the web such as

type Config = JsonProvider<"https://somesite.com/some-file.json", RootName="Config">

The document is read and the properties are available. If that file is altered (added or removed properties) the provider does not refresh this automatically.

I have confirmed this in both FSI and Compiled.

Steps I took to try and get it to refresh and ultimately failed were

  • Break the URL and fix it
  • Rebuild
  • Manually delete the bin and obj directories
  • Unload/reload the project
  • Close/reopen VS
  • Waiting 30 minutes (in-fact I waited several hours as an understanding that the cache is set to 30 minutes)

Workaround

After reaching out to the F# community on their Slack channel I was directed to this line of code that indicated a cache directory in AppData. Only after deleting the DesignTimeURIs directory did the provider refresh and pull in my new properties for me.

Repro steps

  1. Create a json file and host it in a publicly accessible web address
  2. Declare the type in F# using the JsonProvider pointing at the file from the address in step 1
  3. Inspect the type and note the properties available
  4. Alter the original json document and update it to the address
  5. Try the steps I noted in the second section above
  6. Try the Workaround noted above

Setup

Windows 10 64bit 19041.867 Visual Studio Professional 2019 v16.9.0 FSharp.Core 5.0

Let me know if you need any additional information.

fischgeek avatar Apr 14 '21 15:04 fischgeek

Looks like a fix was PR'd in #1365. Leaving open for visibility until approved.

fischgeek avatar Apr 14 '21 15:04 fischgeek