FSharp.Configuration icon indicating copy to clipboard operation
FSharp.Configuration copied to clipboard

Guid like values gets guidified

Open MiloszKrajewski opened this issue 6 years ago • 4 comments

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:

  1. Value field gets defined as string
  2. Actual value is a string, although it may look a little bit like GUID
  3. YamlConfig decided to fix it for me

Expected result: No hyphen should be added

Actual result: 77a66425d680d2925eb032ef6bcd1111 becomes 77a66425-d680-d292-5eb0-32ef6bcd1111

MiloszKrajewski avatar Feb 28 '18 13:02 MiloszKrajewski

type Config = YamlConfig<"...", InferTypesFromStrings = false>

vasily-kirichenko avatar Feb 28 '18 13:02 vasily-kirichenko

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:

  1. neither on compile time nor run time
  2. both, on run time and compile time

MiloszKrajewski avatar Feb 28 '18 14:02 MiloszKrajewski

@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.

airmanx86 avatar Apr 05 '18 06:04 airmanx86

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.

tihomir-kit avatar Jan 18 '22 13:01 tihomir-kit