Skip to content

Refactor SetVariable method signatures to return PSVariable#27407

Open
xtqqczze wants to merge 1 commit into
PowerShell:masterfrom
xtqqczze:SetVariable
Open

Refactor SetVariable method signatures to return PSVariable#27407
xtqqczze wants to merge 1 commit into
PowerShell:masterfrom
xtqqczze:SetVariable

Conversation

@xtqqczze
Copy link
Copy Markdown
Contributor

@xtqqczze xtqqczze commented May 8, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 8, 2026 19:26
@xtqqczze xtqqczze requested a review from a team as a code owner May 8, 2026 19:26
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

Refactors internal session-state variable setting APIs to return PSVariable directly (instead of object), improving type-safety and removing now-unnecessary casts at call sites.

Changes:

  • Updated SessionStateInternal.SetVariable(PSVariable, ...) and the underlying SetVariable(VariablePath, ..., force, ...) overload to return PSVariable.
  • Updated call sites to use the new PSVariable return type without casting.
  • Removed dead/obsolete preprocessor-guarded code in the provider-path branch of SetVariable(VariablePath, ...).

Reviewed changes

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

File Description
src/System.Management.Automation/namespaces/VariableProvider.cs Consumes the new PSVariable return type directly (removes unnecessary as PSVariable cast).
src/System.Management.Automation/engine/SessionStateVariableAPIs.cs Changes SetVariable overload return types to PSVariable and removes dead #if/#else code.
src/System.Management.Automation/engine/MshCommandRuntime.cs Updates pipeline-variable setup to use PSVariable return type directly.

Comment thread src/System.Management.Automation/engine/SessionStateVariableAPIs.cs
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 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/System.Management.Automation/engine/SessionStateVariableAPIs.cs Outdated
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants