Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two problems with TypeProviderConfig.ReferencedAssemblies #13721

Merged
merged 14 commits into from
Oct 7, 2022

Conversation

dsyme
Copy link
Contributor

@dsyme dsyme commented Aug 17, 2022

Fixes #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 #r in 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}"
  • Needs automated tests added.
  • Needs FSharp.Core baseline updated

@dsyme dsyme changed the title Process references in groups in scripts and report incremental updates to ReferencesAssemblies Fix two problems with TypeProviderConfig.ReferencedAssemblies Aug 17, 2022
@dsyme
Copy link
Contributor Author

dsyme commented Aug 20, 2022

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)

@dsyme
Copy link
Contributor Author

dsyme commented Sep 22, 2022

@vzarytovskii This is ready, I've added a test

@dsyme dsyme mentioned this pull request Sep 23, 2022
@vzarytovskii vzarytovskii enabled auto-merge (squash) October 7, 2022 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants