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

Inferred url in yaml config should save AbsoluteUri #148

Open lzybkr opened 5 years ago

lzybkr commented 5 years ago

If I specify a URL in my yaml config, it seems useful to automatically infer the type to be System.Uri, but when saving the type, it doesn't seem useful to write out the properties of System.Uri, instead it should write out just the AbsoluteUri.

Reproduced with 2.0.0-alpha2 - the best workaround I've found is to add something to the sample to force the type to string.

Sample script:

#r "FSharp.Configuration.dll"

open FSharp.Configuration

type Config = YamlConfig<YamlText = "url: http://localhost">

let config = Config()
config.LoadText("url: http://localhost:9999")
config.Save("config.yml")

And the resulting config.yml:

url:
  AbsolutePath: /
  AbsoluteUri: http://localhost:9999/
  LocalPath: /
  Authority: localhost:9999
  HostNameType: Dns
  IsLoopback: true
  PathAndQuery: /
  Segments:
  - /
  Host: localhost
  Port: 9999
  Query: ''
  Fragment: ''
  Scheme: http
  OriginalString: http://localhost:9999
  DnsSafeHost: localhost
  IdnHost: localhost
  IsAbsoluteUri: true
  UserInfo: ''