FSharp.Configuration
FSharp.Configuration copied to clipboard
Yaml type provider: Can't read a list of objects
My config.yaml:
Targets:
- Target: 1 0 1 0
NoSlots: 2
- Target: -1 0 -1 -1
NoSlots: 2
Tiles:
- 1 0 0 0
- 0 0 1 0
- -1 0 0 0
- 0 0 -1 -1
My code:
open FSharp.Configuration
type Config = YamlConfig<"config.yaml">
let config = Config()
printfn "Number of targets: %d" config.Targets.Count
Output: Number of targets: 1
Operating system: Windows Target framework: .net 6 Package version: 2.0.0
Any help to be able to parse the list of objects "Targets" would be much appreciated!
As a workaround, it works if you explicitly load the configuration file at runtime :
open FSharp.Configuration
type Config = YamlConfig<"config.yaml">
let config = Config()
+ config.Load "config.yaml"
printfn "Number of targets: %d" config.Targets.Count
I think we can add a new test to check this scenario automatically.
If no one works on it before, I'm going to take a look later.