Giter Site home page Giter Site logo

The design-time type 'FSharp.Data.Runtime.StructuralInference+InferenceMode' utilized by a type provider was not found about fsharp.data HOT 8 CLOSED

vars-ecco avatar vars-ecco commented on June 18, 2024 1
The design-time type 'FSharp.Data.Runtime.StructuralInference+InferenceMode' utilized by a type provider was not found

from fsharp.data.

Comments (8)

dsyme avatar dsyme commented on June 18, 2024 1

Sigh. Frustratingly unlisting a package doesn't seem to stop nuget from resolving it.

I'll push a 5.0.2 with the package split undone, then work to find a resolution

from fsharp.data.

dsyme avatar dsyme commented on June 18, 2024

I see, thank you. I will unlist the package and get this fixed

from fsharp.data.

dsyme avatar dsyme commented on June 18, 2024

@vars-ecco Do you have a minimal repro script please, with information on how you run it? Thank you

from fsharp.data.

vars-ecco avatar vars-ecco commented on June 18, 2024

@dsyme please see here https://github.com/vars-ecco/ErrorSample

from fsharp.data.

UnoSD avatar UnoSD commented on June 18, 2024

same problem here; this is the code (non-minimal):

#r "nuget: FSharp.Data"
#r "System.Xml.Linq.dll"

open System
open System.Globalization
open FSharp.Data

[<Literal>]
let path = __SOURCE_DIRECTORY__ + "/ALL.xhb"

type ExchangeRateApiGbp =
    JsonProvider<"https://open.er-api.com/v6/latest/GBP">

type ExchangeRateApiUsd =
    JsonProvider<"https://open.er-api.com/v6/latest/USD">

let gbpToEur =
    ExchangeRateApiGbp.GetSample().Rates.Eur

let usdToEur =
    ExchangeRateApiUsd.GetSample().Rates.Eur

type YahooFinanceMsft =
    JsonProvider<"https://query1.finance.yahoo.com/v8/finance/chart/MSFT">

let currentMsftStockPrice =
    YahooFinanceMsft.GetSample().Chart.Result[0].Meta.RegularMarketPrice

let currencySymbol =
    [ "EUR", ""
      "USD", "$"
      "GBP", "£"
      "MSF", "S" ]
    |> Map.ofList

type HomeBank = XmlProvider<path>

try
    let data = HomeBank.GetSample()

    let accounts =
        data.Accounts
        |> Array.map (fun a -> a.Key, a)
        |> Map.ofArray

    let currencies =
        data.Curs
        |> Array.map (fun a -> a.Key, a)
        |> Map.ofArray

    let zpn =
        Environment.GetEnvironmentVariable("ZOOPLA_PROPERTY_NUMBER")

    let currentPropertyEstimateGbp =
        Http.RequestString($"https://www.zoopla.co.uk/property/uprn/{zpn}/", headers = [ "user-agent", "curl/7.84.0" ])
        |> HtmlDocument.Parse
        |> HtmlDocument.descendants false (fun n -> n.HasId("property-estimate"))
        |> Seq.exactlyOne
        |> HtmlNode.descendants false (fun n -> n.HasAttribute("data-testid", "estimate-blurred"))
        |> Seq.exactlyOne
        |> HtmlNode.innerText
        |> (fun s -> s.Replace("£", "").Replace(",", ""))
        |> Decimal.Parse

    // Put all accounts in a summary
    let allAccountSummaries =
        data.Opes
        |> Array.groupBy (fun o -> o.Account)
        |> Array.map (fun (a, o) -> accounts[a], o)
        |> Array.map (fun (a, o) -> a.Name, (o |> Array.sumBy (fun oi -> oi.Amount)) + a.Initial, currencies[a.Curr].Iso)

    // Put all (add property estimate) and convert currency as main label (EUR net worth)
    let netWorth =
        allAccountSummaries
        |> Array.sumBy (fun r -> match r with
                                 | "Fidelity (vested)"  , amount, _     -> amount * currentMsftStockPrice * usdToEur
                                 | "Fidelity (unvested)", _     , _     -> 0m
                                 | _                    , amount, "EUR" -> amount
                                 | _                    , amount, "GBP" -> amount * gbpToEur
                                 | _                                    -> failwith "Unsupported currency")
        |> (fun x -> x + (currentPropertyEstimateGbp * gbpToEur))
    
    let maxAccountNameLength =
        allAccountSummaries
        |> Array.map (fun (name, _, _) -> name.Length)
        |> Array.max
    
    let formatName (name : string) =
        name.Replace(" (EUR)", "").Replace(" (GBP)", "").PadRight(maxAccountNameLength)
    
    let formatAmount (amount : decimal) currency =
        let defaultPadding = 13
        
        let format (amount : decimal) (locale : string) padding =
            String.Format(CultureInfo(locale), "{0:c}", amount).PadRight(padding)
        
        match currency with
        | "USD" -> $"""{format amount "en-US" defaultPadding} ({format (amount * usdToEur) "it-IT" 0})"""
        | "EUR" -> $"""{format amount "it-IT" defaultPadding}"""
        | "GBP" -> $"""{format amount "en-GB" defaultPadding} ({format (amount * gbpToEur) "it-IT" 0})"""
        | "MSF" -> $"""{($"{amount:f2} shares".PadRight(defaultPadding))} ({format (amount * currentMsftStockPrice * usdToEur) "it-IT" 0})"""
        | _     -> failwith "Unsupported currency"
    
    let tooltip =
        allAccountSummaries
        |> Array.sortByDescending (fun (_, amount, _) -> amount)
        |> Array.map (fun (name, amount, currency) -> $"""{formatName name} {formatAmount amount currency}""")
        |> String.concat "\n"

    $"""
    <txt> €{netWorth:n0} </txt>
    <txtclick>homebank</txtclick>
    <tool><tt>{tooltip}</tt></tool>
    """
    |> printfn "%s"
with ex ->
    $"""
    <txt> Error </txt>
    <txtclick>zenity --error --no-wrap --text="{ex.StackTrace}"</txtclick>
    <tool>{ex.Message}</tool>
    """
    |> printfn "%s"

that works on another person's machine.

if I pin the version (even to the latest #r "nuget: FSharp.Data, 4.2.10") it works, if I omit it, I get the same error as above.

pinning is a good workaround for me, sharing the details to help resolve.

thanks

from fsharp.data.

dsyme avatar dsyme commented on June 18, 2024

@UnoSD @vars-ecco I have fixed the problem (via a workaround) and 6.0.1-beta001 is published.

Could I ask you a favour to try this version with your scripts on your machines? I've tried yours @UnoSD and it Works On My Machine ™️

Thanks

from fsharp.data.

UnoSD avatar UnoSD commented on June 18, 2024

@dsyme yep, works well on mine, too. I think the latest (then unlisted, I presume) version was downloaded and cached, hence why it wasn't working and I had to pin. thanks.

from fsharp.data.

vars-ecco avatar vars-ecco commented on June 18, 2024

@dsyme works on my machine as well. thanks!

from fsharp.data.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.