tonerdo / dotnet-env

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

Feature/decouple env vars #105

Open Philipp-Binder opened 2 weeks ago

Philipp-Binder commented 2 weeks ago

Solves #92

Decoupling the concerns of Parsers and Env leads to a more consistent behaviour with different LoadOptions. Namely it solves the different behaviour of Interpolation, when setting SetEnvVars to true or false.

While the parsers main responsibility now is correct parsing and returning the values from the EnvFile, the Env-class takes the responsibility about setting EnvVars, preventing clobber and so on.

With a next step it would be additionally possible to add a LoadOptions-Parameter to be able to ignore (System-)Environment variables at all, which could be a good thing if you work on a system which is polluted with EnvVars by default, and you don't want to see any side effects from your systems EnvVars.

Philipp-Binder commented 2 weeks ago

Just realized some things which are not covered by tests. I need to check that first and come back with some new tests showing these cases.

--> converted to draft

Philipp-Binder commented 1 week ago

I've reworked the whole draft, putting test-cases to the start of the PR.

But right now I will postpone the work here until the migration to superpower in #106 is completed.

rogusdev commented 8 hours ago

I like the look of this! Please update for the superpower merge, and I'll go over more granularly. But I very much like where this is headed.

Philipp-Binder commented 6 hours ago

Updating to superpower-stuff was kinda easy, but still I need to invest some time and comment some cases. E.g. there are breaking changes to be discussed, I tried to have none, but that was not possible in the end.

I will come back here soon.