Skip to content

Workaround for target assemblies where packages with transitive references contain type providers #388

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

Merged
merged 6 commits into from
Aug 17, 2022

Conversation

dsyme
Copy link
Contributor

@dsyme dsyme commented Aug 17, 2022

Enables type providers to get the correct set of target assemblies when nuget packages with transitive references to other packages contain type providers, and these are used in scripts.

This is a workaround for F# tooling bug dotnet/fsharp#13710 where the type providers are instnatiated before the complete set of references relevant to a nuget package are reported correctly by ReferencedAssemblies

// The 'ReferencedAssemblies' reported to type providers by TypeProviderConfig have a problem in scripting scenarios
// involving incremental additions to the referenced assembly set, see 
//
//   https://github.com/dotnet/fsharp/issues/13710
//
// There is a long-standing reflection hack to determine the set of
// referenced assemblies by reflecting over the SystemRuntimeContainsType
// closure in the TypeProviderConfig object.
//
// We removed the use of this hack in 2019, however the bug above indicates that
// it is still necessary when type providers have transitive nuget package references
// relevant to the public surface area of the provided types.
//
// Further, the ReferencedAssemblies need to be evaluated "late", after the type provider
// has been created, because additional references may be added to the compilation context by
// processing further #r references implied by a set of nuget packages. This will be addressed
// in the core F# tooling as part of fixing the bug above by instead simultaneously registering
// all `#r` implied by a load script. However until it is fixed we need to delay the recomputation
// of the referenced assemblies.

The "proper" F# tooling fix for dotnet/fsharp#13710 is for F# tooling to register all transitive referenced assemblies implied by a nuget package reference simultaneously, and thus report ReferencedAssemblies correctly.

The workaround for getting referenced assemblies was removed here: #305. We will eventually be able to remove the workaround again once a proper fix for dotnet/fsharp#13710 propagates through the F# tooling ecosystem for all tooling that loads type providers.

@dsyme dsyme changed the title Use correct referenced target assemblies in scripting scenarios Workaround to get correct referenced target assemblies in scripting scenarios where nuget packages contain type providers with transitive nuget references Aug 17, 2022
@dsyme dsyme changed the title Workaround to get correct referenced target assemblies in scripting scenarios where nuget packages contain type providers with transitive nuget references Workaround for target assemblies where packages with transitive package references contain type providers Aug 17, 2022
@dsyme dsyme changed the title Workaround for target assemblies where packages with transitive package references contain type providers Workaround for target assemblies where packages with transitive references contain type providers Aug 17, 2022
@dsyme dsyme merged commit 7ea7cde into master Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant