Do not generate clean block in proxy command when the feature is disabled by daxian-dbw · Pull Request #17112 · PowerShell/PowerShell · GitHub
Skip to content

Do not generate clean block in proxy command when the feature is disabled#17112

Merged
daxian-dbw merged 1 commit intoPowerShell:masterfrom
daxian-dbw:clean
Apr 5, 2022
Merged

Do not generate clean block in proxy command when the feature is disabled#17112
daxian-dbw merged 1 commit intoPowerShell:masterfrom
daxian-dbw:clean

Conversation

@daxian-dbw
Copy link
Copy Markdown
Member

@daxian-dbw daxian-dbw commented Apr 5, 2022

PR Summary

Fix #17110
When the PSCleanBlock experimental feature is not enabled, ProxyCommand.Create should not generate the clean block for the proxy function.

After the fix,

  1. when the feature is disabled, generated proxy function for Get-Command doesn't have the clean block in it:

    PS:4> [System.Management.Automation.ProxyCommand]::Create($cm)
    [CmdletBinding(DefaultParameterSetName='CmdletSet', HelpUri='https://go.microsoft.com/fwlink/?LinkID=2096579')]
    param(
       .... ## skip the long param block
       )
    
    begin
    {
        ... ## skip the long begin block
    }
    
    process
    {
        try {
            $steppablePipeline.Process($_)
        } catch {
            throw
        }
    }
    
    end
    {
        try {
            $steppablePipeline.End()
        } catch {
            throw
        }
    }
    
    <#
    
    .ForwardHelpTargetName Microsoft.PowerShell.Core\Get-Command
    .ForwardHelpCategory Cmdlet
    
    #>
  2. When the feature is enabled, the generated proxy function for Get-Command has the clean block in it:

    PS:3> [System.Management.Automation.ProxyCommand]::Create($cm)
    [CmdletBinding(DefaultParameterSetName='CmdletSet', HelpUri='https://go.microsoft.com/fwlink/?LinkID=2096579')]
    param(
       ... ## skip the long param block
        )
    
    begin
    {
        ... ## skip the long begin block
    }
    
    process
    {
        try {
            $steppablePipeline.Process($_)
        } catch {
            throw
        }
    }
    
    end
    {
        try {
            $steppablePipeline.End()
        } catch {
            throw
        }
    }
    
    clean
    {
        if ($null -ne $steppablePipeline) {
            $steppablePipeline.Clean()
        }
    }
    
    <#
    
    .ForwardHelpTargetName Microsoft.PowerShell.Core\Get-Command
    .ForwardHelpCategory Cmdlet
    
    #>

PR Checklist

@pull-request-quantifier-deprecated
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@PaulHigin PaulHigin left a comment

Choose a reason for hiding this comment

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

LGTM

@daxian-dbw daxian-dbw added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Apr 5, 2022
@daxian-dbw daxian-dbw assigned daxian-dbw and unassigned PaulHigin Apr 5, 2022
@daxian-dbw daxian-dbw merged commit 7cc9c87 into PowerShell:master Apr 5, 2022
@daxian-dbw daxian-dbw deleted the clean branch April 5, 2022 19:00
@PaulHigin
Copy link
Copy Markdown
Contributor

This breaks JEA as it uses RestrictedSessions, so we should consider for backport.

@daxian-dbw
Copy link
Copy Markdown
Member Author

The clean block is new to PS 7.3 preview (I think available in 7.3-preview.1), so no backport is needed.

@ghost
Copy link
Copy Markdown

ghost commented May 23, 2022

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

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Extra Small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProxyCommand.Create method creates clean block when clean block experimental feature is disabled

3 participants