You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Init method in Env.cs for better initialization (#906)
* Refactor Init method in Env.cs for better initialization
Reordered the Init method to check _initialized flag at the start,
ensuring early return if already initialized. Moved _env dictionary
initialization before the check to guarantee setup before any
operations. Removed _initialized flag setting and env.json reading
from the try block, simplifying the initialization logic.
* Ensure _initialized is set only after successful deserialization
Moved _initialized = true; to after JSON deserialization to ensure
it is only set if deserialization is successful. Added a catch block
for JsonException to handle parsing errors and output an error
message to the console.
* Refactor path handling and update StreamReader syntax
Refactored code for better readability and robustness:
- Declared `path` as a `string`.
- Ensured `path` ends with a directory separator.
- Updated `StreamReader` initialization to new C# syntax.
* Refactor file path construction for "env.json"
Simplified the process of constructing the file path for "env.json" by replacing manual checks and concatenation with `Path.Combine`. This change makes the code more concise and less error-prone by leveraging built-in functionality for path handling.
0 commit comments