Skip to content

Add EnvironmentExtensions with RefreshEnvironmentVariables - #19

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

Tyrrrz merged 13 commits into
primefrom
copilot/add-environment-extensions

Conversation

Copilot AI commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

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()).

@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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Copilot AI requested a review from Tyrrrz April 14, 2026 15:06
@Tyrrrz
Tyrrrz requested a review from Copilot April 14, 2026 15:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Tyrrrz

Tyrrrz commented Apr 14, 2026

Copy link
Copy Markdown
Owner

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

Copilot AI commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

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