fsprojects / FSharp.TypeProviders.SDK

The SDK for creating F# type providers
https://fsprojects.github.io/FSharp.TypeProviders.SDK/
MIT License
298 stars 94 forks source link

writeBinaryAndReportMappings() needs type annotation #261

Closed juselius closed 5 years ago

juselius commented 5 years ago

Description

Trying to compile a trivial type provider with recent versions of ProvidedTypes.fs fails to find unique overload for method 'GetDirectoryName' in writeBinaryAndReportMappings().

Repro steps

module Acme

open System
open System.Reflection
open ProviderImplementation
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Quotations

[<TypeProvider>]
type NoProvider (config : TypeProviderConfig) as this =
    inherit TypeProviderForNamespaces (config)

    let ns = "Nothing.Provided"
    let asm = Assembly.GetExecutingAssembly()
    let t = ProvidedTypeDefinition(asm, ns, "Empty", Some typeof<obj>)
    do this.AddNamespace(ns, [t])

[<assembly:TypeProviderAssembly>]
do ()

Expected behavior

I expect the code to compile without errors.

Actual behavior

ProvidedTypes.fs(12620,31): error FS0041: A unique overload for method 'GetDirectoryName' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: Path.GetDirectoryName(path: ReadOnlySpan<char>) : ReadOnlySpan<char>, Path.GetDirectoryName(path: string) : string

Known workarounds

Add a type annotation of type string to the outfile argument of writeBinaryAndReportMappings()

Related information

dsyme commented 5 years ago

Fixed, thanks! I believe this only happens when tareting .NET 4.7.1

juselius commented 5 years ago

Excellent! Actually I'm targeting netcoreapp2.1.