tonerdo / dotnet-env

A .NET library to load environment variables from .env files
MIT License
427 stars 50 forks source link

refactor/DictionaryExtension #88

Closed Philipp-Binder closed 9 months ago

Philipp-Binder commented 9 months ago

!BREAKING CHANGE! Refactor KeyValuePair-Linq-Extension to use a CreateDictionaryOption. Breaks running code, because dupes will throw now by default, but makes the behavior of ToDictionary() on KeyValuePair to return the expected results.

You easily take that extension outside of the DotEnv-scope by fault, where you would expect it to throw on dupes rather than taking the last occurrence. Especially since all IDEs heavily encourage you to add usings more or less automagically, and due to the high expectations about Linq-Extensions handling so much List-Work, you just don't recognize that this ToDictionary method will not do what you really expect.

That is one of the main reasons why I do not use this library at the moment, but I would really like to see this repo evolving a little bit further and then using it too.

rogusdev commented 9 months ago

This is an interesting and acceptable change, except for breaking current behavior. Name the base one "throw" instead of "default" and then actually put a default into the To dictionary method signature that is the current behavior (take last). Then this is pure value add and not a breaking change.