PowerShell / PowerShell/PowerShell

Allow `$PSCmdlet` methods in constrained language

未关闭
#17,906 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Issue-Enhancement Needs-Triage WG-Cmdlets WG-Reviewed WG-Security
主要语言
C#
星标
55.5k
派生
8.5k
平均合并
1 天 2 小时
30 天内合并 PR
88

描述

Summary of the new feature / enhancement

The following fails when using constrained language mode:

function Test-ShouldProcess {
     [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
     param()

     if($PSCmdlet.ShouldProcess('something')) {
         return $true
     }
}

Error:

Cannot invoke method. Method invocation is supported only on core types in this language mode.

Other usages are also blocked, such as getting preference variables from caller scope within modules:

  param (
    $VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference')
  )
Proposed technical implementation details (optional)

No response

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先在受限语言模式下重现 ShouldProcess 和 GetVariableValue 示例,然后跟踪受限语言中的方法调用处理。定义允许使用的 $PSCmdlet 方法,并验证这些调用能够正常工作,同时不放宽对其他方法调用的限制。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, powershell
领域
cli, security
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。