Skip to content

v2.0.0

Compare
Choose a tag to compare
@MrDave1999 MrDave1999 released this 29 Mar 17:07
· 306 commits to master since this release

New features

  • Added another type of error handling with the EnvValidationResult class. (#13, #18)
    • To use this feature you must use the Load(out EnvValidationResult) method of the EnvLoader class.
  • Added support for .env file loads based on environment (development, test, staging, or production). (#14, #19)
    • To use this feature you must use the LoadEnv method of the EnvLoader class.
  • The parser and loader now throws an exception with all errors encountered instead of one at a time. (#16, #17, #18)
  • Added the SetEnvironmentName method to the EnvLoader class. (#22, #23)
  • Added support for loading .env files without modifying the environment. (#20, #21)
    • To use this feature you must use the AvoidModifyEnvironment method of the EnvLoader class.
  • Added a new Env helper class to perform checks with the current environment. (#24, #25)
  • Added the HasValue method to the EnvReader class. (#26, #50)
  • Added checks to some methods in case the parameter is null. (#36, #37)
  • Added the SetEncoding(string) and AddEnvFile(string, string) method to the EnvLoader class. (#38, #39)
  • Added the EnvValidator class that validates whether the keys required by the application exist in the current environment. (#42, #43)
  • Added a configuration method to indicate that a .env file is optional. (#44, #46)
  • Added a configuration method to indicate that all .env files should be optional. (#45, #47)
    • To use this feature you must use the AllowAllEnvFilesOptional method of the EnvLoader class.
  • Added a configuration method to tell the loader to ignore parent directories. (#52, #54)
  • Added a configuration method to set the environment variables provider. (#51, #53)
  • Added a new format in the error messages. (#60, #63)
  • Added support for embedding variables in the keys. (#62, #64)

Fixed bugs

  • Fixed the problem with the LoadEnv method not maintaining .env files priority. (#31, #32)
  • Fixed the problem with the loader does not search for the .env file in parent directories when the path is absolute. (#55, #56)
  • Fixed the problem that DOTNET_ENV is not set when the environment name is defined from the source code. (#61, #65)

API changes

Important changes in the current API:

  • Changed the return value type of the EnvParser.Parse and EnvLoader.Load methods to IEnvironmentVariablesProvider.
  • Added a parameterized constructor to the EnvReader class so that it depends on the IEnvironmentVariablesProvider interface. (#48, #49)
  • The EnvVariableNotFoundException class was replaced by VariableNotSetException.
  • The name of the method IgnoreParserExceptions has been changed to IgnoreParserException.
  • Removed None option from ConcatKeysOptions enum.
  • Removed parameters: actualValue, currentLine from the parameterized constructor of the ParserException class.
  • It is no longer possible to override the helper methods of the EnvParser class. (#40)
    This new version follows the encapsulation principle: "The fewer implementation details the client knows, the fewer changes they will have to make".
    • The fields and methods that were protected were changed to private in the EnvParser class.
    • The parameterized constructor of the EnvLoader class was removed.

Other changes