Skip to content

type provider ResolutionFolder is empty #1868

@zanaptak

Description

@zanaptak

Description

I have a type provider (as do others) for use with Fable. It erases to strings, and works great for the most part.

However, there is one problem: during the Fable compilation process, the type provider's ResolutionFolder configuration property, which is supposed to be the .fsproj directory, does not get set.

Type providers are somehow instantiated with a TypeProviderConfig object like so: type MyTypeProvider (config:TypeProviderConfig) as this = ...

When compiled by Fable (or F# compiler services, or however they are interacting), the config object has the other properties set but not the ResolutionFolder. Consequently, at compilation time we have no way to find source data files with paths relative to project root, we can only find absolute paths.

Here is some debug logging from my type provider to illustrate this further.

At design time in VS Code it sets the ResolutionFolder:

Creating TypeProviderForNamespaces Zanaptak.TypedCssClasses.TypeProvider+CssClassesTypeProvider [0]
TypeProviderConfig.IsHostedExecution = false
TypeProviderConfig.IsInvalidationSupported = true
TypeProviderConfig.TemporaryFolder = C:\Users\zaphod\AppData\Local\Temp\
TypeProviderConfig.ResolutionFolder = c:\src\testTypedCss\src
TypeProviderConfig.RuntimeAssembly = c:\src\TypedCssClasses\src\bin\Debug\netstandard2.0\Zanaptak.TypedCssClasses.dll
TypeProviderConfig.ReferencedAssemblies count = 123
    C:\Users\zaphod\.nuget\packages\fsharp.core\4.6.2\lib\netstandard1.6\FSharp.Core.dll
    C:\Users\zaphod\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\Microsoft.Win32.Primitives.dll
    C:\Users\zaphod\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\mscorlib.dll
    C:\Users\zaphod\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\netstandard.dll
    C:\Users\zaphod\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.AppContext.dll
    ...
Environment.CommandLine = C:\Users\zaphod\.vscode\extensions\ionide.ionide-fsharp-4.0.6\bin_netcore\fsautocomplete.backgroundservices.dll 23332
Environment.CurrentDirectory = c:\src\testTypedCss

If I build with dotnet build .\src\App.fsproj, it sets the ResolutionFolder (also changing current working dir):

Creating TypeProviderForNamespaces Zanaptak.TypedCssClasses.TypeProvider+CssClassesTypeProvider [0]
TypeProviderConfig.IsHostedExecution = false
TypeProviderConfig.IsInvalidationSupported = false
TypeProviderConfig.TemporaryFolder = C:\Users\zaphod\AppData\Local\Temp\
TypeProviderConfig.ResolutionFolder = C:\src\testTypedCss\src
TypeProviderConfig.RuntimeAssembly = C:\src\TypedCssClasses\src\bin\Debug\netstandard2.0\Zanaptak.TypedCssClasses.dll
TypeProviderConfig.ReferencedAssemblies count = 123
    C:\Users\zaphod\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\netstandard.dll
    C:\Users\zaphod\.nuget\packages\fsharp.core\4.6.2\lib\netstandard1.6\FSharp.Core.dll
    C:\Users\zaphod\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\Microsoft.Win32.Primitives.dll
    C:\Users\zaphod\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\mscorlib.dll
    C:\Users\zaphod\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.AppContext.dll
    ...
Environment.CommandLine = "C:\Program Files\dotnet\sdk\3.0.100-preview5-011568\FSharp\fsc.exe" @C:\Users\zaphod\AppData\Local\Temp\tmp748d72f3b53a4861ad2f55279ffa7343.rsp
Environment.CurrentDirectory = C:\src\testTypedCss\src

If I build with webpack which runs Fable.Cli.dll, the folder is empty string (not null, in case it matters):

Creating TypeProviderForNamespaces Zanaptak.TypedCssClasses.TypeProvider+CssClassesTypeProvider [0]
TypeProviderConfig.IsHostedExecution = false
TypeProviderConfig.IsInvalidationSupported = false
TypeProviderConfig.TemporaryFolder = C:\Users\zaphod\AppData\Local\Temp\
TypeProviderConfig.ResolutionFolder is empty string
TypeProviderConfig.RuntimeAssembly = C:/src/TypedCssClasses/src/bin/Debug/netstandard2.0/Zanaptak.TypedCssClasses.dll
TypeProviderConfig.ReferencedAssemblies count = 120
    C:/Users/zaphod/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/netstandard.dll
    C:/Users/zaphod/.nuget/packages/fsharp.core/4.6.2/lib/netstandard1.6/FSharp.Core.dll
    C:/Users/zaphod/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.XPath.XDocument.dll
    C:/Users/zaphod/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.XPath.dll
    C:/Users/zaphod/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.XmlSerializer.dll
    ...
Environment.CommandLine = C:\src\testTypedCss\node_modules\fable-compiler\bin\fable-cli\Fable.Cli.dll start-stdin --silent undefined
Environment.CurrentDirectory = C:\src\testTypedCss

I started to poke around the Fable codebase but quickly got lost so I'm asking here. Do you think it might be possible to figure out how to set this property correctly? I can also provide a test project if necessary if someone is willing and able to dig further.

Related information

  • Fable version: 2.3.14
  • Operating system: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions