fsprojects / FSharp.Configuration

The FSharp.Configuration project contains type providers for the configuration of .NET projects.
http://fsprojects.github.io/FSharp.Configuration/
Other
114 stars 63 forks source link

Guid like values gets guidified #138

Open MiloszKrajewski opened 6 years ago

MiloszKrajewski commented 6 years ago

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

vasily-kirichenko commented 6 years ago
type Config = YamlConfig<"...", InferTypesFromStrings = false>
MiloszKrajewski commented 6 years ago

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

airmanx86 commented 6 years ago

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

tihomir-kit commented 2 years ago

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.