Fix two problems with TypeProviderConfig.ReferencedAssemblies
Fixes https://github.com/dotnet/fsharp/issues/13710 - two problems with the F# tooling when instantiating type providers from packages that have nuget dependencies. In particular TypeProviderConfig.ReferencedAssemblies was reporting incorrect results after splitting FSharp.Data into multiple components.
This is not time-critical because I've worked around this in FSharp.TypeProviders.SDK and FSharp.Data by re-activating an ugly hack that we had in place some time ago when TypeProviderConfig.ReferencedAssemblies was also producing incorrect results. However I've prepared the essence of the fixes now while the details are fresh in my mind.
The two fixes:
-
A group of sequential
#rin a script should be processed together, meaning each should be resolved, and then all added into TcImports at once. This is important when processing the set of assemblies implied by a nuget package reference, because the process of adding the assemblies into TcImports will create any type provider instances, and these in turn will want to see the complete set of available referenced assemblies via TypeProviderConfig.ReferencedAssemblies. -
Further, the referenced assemblies can grow incrementally as more referenced assemblies are added by further
#r. These should be reliably reported to the type provider instance, since the type provider may later be used with types from these assemblies. -
In order to make the first fix accurately I've cleaned up a fair bit of
fsi.fs(renaming, some indentation, some removal of duplicate code).
I've tested manually. For example this one, which was failing and now passes:
#r "nuget: FSharp.Data, 5.0.1"
open FSharp.Data
type Auth = JsonProvider<"""{ "test": 1 }""">
let auth = Auth.Parse("""{ "test": 1 }""")
printfn $"{auth.Test}"
- [x] Needs automated tests added.
- [x] Needs FSharp.Core baseline updated
Different paths in printing tests:
2022-08-19T15:56:39.4580448Z - --> Referenced 'C:/Users/dsyme/.nuget/packages/newtonsoft.json/13.0.1/lib/net45/Newtonsoft.Json.dll' (file may be locked by F# Interactive process)
2022-08-19T15:56:39.4582311Z + --> Referenced 'C:/Users/cloudtest/.nuget/packages/newtonsoft.json/13.0.1/lib/net45/Newtonsoft.Json.dll' (file may be locked by F# Interactive process)
@vzarytovskii This is ready, I've added a test