Open devtxdotnet opened 8 years ago
We infer 012
as int because it can be parsed as int without errors. Could you suggest a way to say the TP that 012
is a string, not an integer?
After parsing any string to a number these number could be converted back to a string and when these string is not equal to the parsed one the parsing should fail. But I have seen that these behavior will clash with the actual behavior for both integer and floating-point number parsing. And I do not know if the current behavior is intended.
We need to look at how types are inferred in FSharp.Data project.
They do for example Int32.TryParse(TextConversions.RemoveAdorners text, NumberStyles.Integer, cultureInfo)
but their domain is different I would say. In an app.setting file I would expect that any value should be used as it is because they are configurations. In the context of big data analysis there are fuzzy values. I would expect that my configuration values are not changed at all. There should be no fuzziness when configuration values are parsed. What do you think about that?
What about a static parameter, which would force the TP to make all properties to be of type string
?
Like this:
type T = AppSettings<"app.config", InferTypes = false>
But what is then the benefit of the type provider? In that case I could still use the configuration manager.
I don't know :) I've not used app.config
s for years (I've used yaml instead).
When an app setting value has a leading zero "0" for examle "CatalogId" "012" the type AppSettings has a property "CatalogId" of type int and the value 12.
It should be instead of type string so that the leading zero is not lost, because 12 is not the same as 012.
Actually I have to insert a leading character for example "z012" as a value to force "CatalogId" to be of type string.
Robert Niemann