Json The gens type provided does not work with "with"

Here's a snippet that demonstrates what I'll be talking about well:

open FsCheck
open FsCheck.Gen
open FSharp.Data

type Test = JsonProvider<"""{"collection": [ { "Name": "Rob", "Age": 3 } ] } """>
let testGen () = 
  gen {
       let! name = Arb.generate<string>
       let! age  = Arb.generate<int>
       let colObj = Test.Collection(name, age)
       return Test.Root([|colObj|])
      }

let specialTestGen () = 
  gen {
       let! test = testGen ()
       let item = test.Collection.[0]
       let foo = item.Name
       let changedItem = {item with Name = "Chris"}
       return {test with test.collection = [|changedItem|]}
      }

      

I am trying to create a gene with some gen'd fields all the time. I can assign foo the name of the collection instance, but for some reason I cannot build another slightly modified version of stuct. He tells me that the element does not have a property called "Name" when it is clearly on the line in front of it. Can I use the syntax "with" these libraries for some reason?

+3


source to share


1 answer


Type providers can only provide regular .NET types now, not F # records and discriminatory joins. The syntax {x with ...}

is for F # entries only.



+4


source







All Articles