F# provides reflection that let's you, amongst other things, generate new values of function, tuple, record and union types at run-time. However, I cannot see anything in that module pertaining to anonymous records.
Is it possible to create new values of anonymous record types at run-time in F#?
The FSharp.Reflection.FSharpValue.MakeRecord
method works for anonymous records just as well as for nominal ones:
let x = {| a = "b"; c = 42 |}
ley y = FSharp.Reflection.FSharpValue.MakeRecord( x.GetType(), [| "foo"; 5 |] )
> val it : obj = {a = "foo"; c = 5;}
Or did I misunderstand the question?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With