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

Make inferring types from strings optional for Yaml provider #114

Closed alfonsogarciacaro closed 7 years ago

alfonsogarciacaro commented 7 years ago

Hi there! We started to have problems with the YamlConfig provider in our project because we've lists where some items look and quack like Guids, so the provider infers the field type to be a Guid list, but we want to be able to put other plain strings in that list and the provider doesn't let us do that as it fails when it tries to cast everything into a guid. This affects also TimeSpan and Uri-looking strings.

I'd like to send a PR to make inferring types from strings optional. I gave it a shot at adding another static parameter to YamlConfig and using a mutable value in Parser (to avoid too much refactoring) but unfortunately it didn't work, and this solution would also be breaking (besides not very elegant) as it seems it's not possible to have optional static parameters.

So before sending a PR, I want to ask the maintainers if they can think of a good approach to this problem.

vasily-kirichenko commented 7 years ago

Implemented in https://github.com/fsprojects/FSharp.Configuration/pull/115 and published in NuGet 1.0.0

image

alfonsogarciacaro commented 7 years ago

Awesome, thanks!