FSharp.Configuration
FSharp.Configuration copied to clipboard
Guid like values gets guidified
YamlConfig
(or underlying SharpYaml.dll
) lets itself to parse string values behind my back.
Example:
#r "FSharp.Configuration.dll"
open FSharp.Configuration
type Config = YamlConfig<YamlText = "Value: some text"> // <-- 1
let config = Config()
config.LoadText("Value: 77a66425d680d2925eb032ef6bcd1111") // <-- 2
printfn "%s" config.Value // 77a66425-d680-d292-5eb0-32ef6bcd1111 // <-- 3
Note:
- Value field gets defined as string
- Actual value is a string, although it may look a little bit like GUID
- YamlConfig decided to fix it for me
Expected result: No hyphen should be added
Actual result:
77a66425d680d2925eb032ef6bcd1111
becomes 77a66425-d680-d292-5eb0-32ef6bcd1111
type Config = YamlConfig<"...", InferTypesFromStrings = false>
This is kind-of what I want but not exactly. It seems like it does not infer types on compile time anymore.
I do want it to infer types, but on compile time only (YamlConfig<YamlText = "Value: some text">
) not on run time (config.LoadText("Value: 77a66425d680d2925eb032ef6bcd1111")
).
It seem like options currently are:
- neither on compile time nor run time
- both, on run time and compile time
@vasily-kirichenko I have similar problem and InferTypesFromStrings = false
does help. It would be nice if we can only turn off certain config value like through defining a schema (json schema?) similar to the CSV provider.
I think it's incorrect to assume that something that doesn't contain dashes is a Guid just because of the amount of other characters and potentially the character set. It's simply not the same format.
Other type inferences might be useful to have still, so it also doesn't make a lot of sense to disable all inferences just to avoid incorrect Guid parsing.