Skip to content

Add EnvironmentExtensions with RefreshEnvironmentVariables#19

Merged
Tyrrrz merged 13 commits intoprimefrom
copilot/add-environment-extensions
Apr 14, 2026
Merged

Add EnvironmentExtensions with RefreshEnvironmentVariables#19
Tyrrrz merged 13 commits intoprimefrom
copilot/add-environment-extensions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Ports EnvironmentExtensions.RefreshEnvironmentVariables from DotnetRuntimeBootstrapper into PowerKit.

Changes

  • EnvironmentExtensions.cs — new extension on Environment with a single method RefreshEnvironmentVariables() that fully synchronizes the current process environment with both machine-level and user-level environment variables: variables removed from machine or user scope are also removed from the process, machine-level variables are applied first, and user-level variables are applied on top (so user values win on key conflicts, matching Windows process-start behavior)
Environment.RefreshEnvironmentVariables();

The method is a no-op on non-Windows platforms (guarded via OperatingSystem.IsWindows()).

Copilot AI and others added 2 commits April 12, 2026 18:46
@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 14, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review April 14, 2026 11:00
Copilot AI review requested due to automatic review settings April 14, 2026 11:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new EnvironmentExtensions utility to PowerKit to refresh the current process environment by re-applying machine-level environment variables.

Changes:

  • Introduces EnvironmentExtensions.RefreshEnvironmentVariables() as an extension on Environment
  • Reads machine-level variables via Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine) and writes them into EnvironmentVariableTarget.Process

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit/Extensions/EnvironmentExtensions.cs Outdated
Comment thread PowerKit/Extensions/EnvironmentExtensions.cs
Comment thread PowerKit/Extensions/EnvironmentExtensions.cs Outdated
…on non-Windows

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/aecbef3b-355c-4735-b2e4-3f82f17555be

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/3d8fa311-0f4c-4f8f-94bf-a6b79d0b081e

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Comment thread PowerKit/Extensions/EnvironmentExtensions.cs Outdated
Copilot AI requested a review from Tyrrrz April 14, 2026 15:06
@Tyrrrz Tyrrrz requested a review from Copilot April 14, 2026 15:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit/Extensions/EnvironmentExtensions.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 14, 2026

@copilot what should we do about user-level variables?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 14, 2026

@copilot what should we do about user-level variables?

Updated in 125c131. The method now reads both EnvironmentVariableTarget.Machine and EnvironmentVariableTarget.User, applies machine variables first and then user variables (so user values win on key conflicts, matching Windows process-start behavior), and only removes process variables that are absent from both scopes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit/Extensions/EnvironmentExtensions.cs
Comment thread PowerKit/Extensions/EnvironmentExtensions.cs Outdated
Tyrrrz and others added 3 commits April 14, 2026 18:37
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants