aloneguid / config

⚙ Config.Net - the easiest configuration framework for .NET developers. No BS.
MIT License
656 stars 86 forks source link

Bool alias conversion from core parsers produces unexpected results when writing #73

Closed maelgrove closed 6 years ago

maelgrove commented 6 years ago

The current CoreParsers.cs allow converting to boolean values from alias strings like "yes", "true", "1", "no" etc. While this seems quite handy at a first glance, it produces unexpected results when writing a boolean value back, since the ToRawString method of the core parsers might end up converting to a different value since it basically just converts the boolean value to string, without respecting a previous "alias".

So basically if a user prefers to write "1" instead of "true", an application loads a configuration file, sets the value internally to true and saves it back, the resulting file might contain "true" instead of "1". This is unexpected behavior.

Possible solutions would be either take note of the original alias type, or remove the feature completely.

aloneguid commented 6 years ago

Hm from what i remember many years ago it was done because configs were edited by non technical people and we had issues parsing correct values back, this was primary reason.

The issue with remembering original syntax is that value may be written to a store different from where it was read, or it may not exist at all. Hence it's written in the most common form true/false. I guess this may cause issues when configs are shared between applications that expect slightly different syntax, but we had none so far. I find it handy personally not having to answer support calls and let allowances to be made for normal users, rather that throwing exceptions or defaulting to not what's meant to be. I may be wrong .

maelgrove commented 6 years ago

I can definitely understand the intention behind it, but I've got a few other thoughts concerning this based on what I learnt from working in a huge company with primarily non-tech-savvy clients:

maelgrove commented 6 years ago

Closing since possible solution with 'strict' parsing mode.