I've encountered some strange behaviour when trying to open a library that uses a JsonProvider with an embedded resource.
Given then following module defined in a separate library:
module MyLib
open FSharp.Data
type MyJsonConfig = JsonProvider<"sample.json", EmbeddedResource="MyLib, sample.json">
type MyFoo = { Foo : string }
let loadMyConfig (path : string) =
let config = MyJsonConfig.Load(path)
{ Foo = config.Foo }
And the following program that references and consumes MyLib:
open System
open MyLib
[<EntryPoint>]
let main argv =
let config = loadMyConfig("config.json")
printfn "Loaded config: %A" config
printfn ""
printfn "Press any key to exit"
Console.ReadKey() |> ignore
0
I get the following compilation error:
Error FS3033 The type provider 'ProviderImplementation.JsonProvider' reported an error: An index satisfying the predicate was not found in the collection.
For this simple example, there is a workaround to avoid this error: Instead of opening MyLib, use the fully-qualified name when referencing loadMyConfig (i.e. MyLib.loadMyConfig).
There is also an Intellisense issue regardless of whether the workaround is used: If you attempt to dot into MyLib (i.e. type MyLib.), Intellisense will show the same error reported above.
I have put together a repro here: https://github.com/ScottShingler/JsonProviderEmbeddedRepro
I should also mention that I'm experiencing the same compilation error in another project, but the workaround of not opening the library module is not solving it. Unfortunately I am unable to share that code since it's proprietary, but I expect the root cause of this issue should be related.