PowerShell / PowerShell/PowerShell
Allow `$PSCmdlet` methods in constrained language
未关闭
还没有人认领这个 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在受限语言模式下重现 ShouldProcess 和 GetVariableValue 示例,然后跟踪受限语言中的方法调用处理。定义允许使用的 $PSCmdlet 方法,并验证这些调用能够正常工作,同时不放宽对其他方法调用的限制。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, powershell
- 领域
- cli, security
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100