Skip to content

In scripts, TypeProviderConfig.ReferencedAssemblies doesn't always include package-transitive or incremental assembly references  #13710

@dsyme

Description

@dsyme

When instantiating a type provider we pass it a TypeProviderConfig. This includes a ReferencedAssemblies property that reports the compilation context.

However, consider a script when referencing a component that has transitive nuget package dependencies:

#r "nuget: FSharp.Data, 5.0.1"

open FSharp.Data
type Auth = JsonProvider<"""{ "test": 1 }""">
let auth = Auth.Parse("""{ "test": 1 }""")
printfn $"{auth.Test}"

Here FSharp.Data 5.0.1 has multiple transitive package references such as FSharp.Data.Json.Core, 5.0.1.

The type providers in FSharp.Data.dll are instantiated as soon as the implied #r for FSharp.Data.dll is processed, which is before the transitive references. This is because the individual #r implied for #r "nuget: ..." declarations are processed one by one in some arbitrary order. This means the reported reference set is not complete.

Additionally, in a dynamic F# Interactive context, the ReferencedAssemblies in the TypeProviderContext do not later report any additional #r to individual DLLs - it only reports the references as they are precisely at the point where the reference to the type provider assembly is processed. (Note this only affects explicit assembly references, which can be manually reordered).

This only affects scripting. See fsprojects/FSharp.Data#1459

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions