PowerShell / PowerShell/PowerShellEditorServices

Clear secondary streams on primary PowerShell object

未关闭
#791 2 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Area-Extension Terminal Issue-Enhancement
主要语言
C#
星标
767
派生
266
平均合并
3 天 16 小时
30 天内合并 PR
1

描述

Currently we reuse the same PowerShell object for every script invocation/prompt evaluation, but we aren't clearing the streams afterward. Example:

PS> $context = $psEditor.Components.Get([Microsoft.PowerShell.EditorServices.PowerShellContext])
PS> $ps = $context.GetType().GetField('powerShell', 60).GetValue($context)
PS> $ps.Streams.Information
# <Empty>
PS> Write-Host 'first message'
PS> $ps.Streams.Information
# first message
PS> Write-Host 'second message'
PS> $ps.Streams.Information
# first message
# second message

Same for the other streams e.g. warning, verbose, debug, and progress (even though progress is not shown, the record is still stored until the end of the session)

Depending on how long the PSIC is left open and how much these streams are being written to, this could be the cause of some reported memory usage issues.

贡献指南

打开贡献指南

从这里开始

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

调研方向

从复用主 PowerShell 对象来执行脚本调用和提示评估的代码开始,然后检查其 Streams.Information、warning、verbose、debug 和 progress 集合。复现 issue 中显示的累积情况,并跟踪每次调用何时完成。完成的标准是,次级流记录不会在调用之间持续存在,包括 progress 记录;如果存在相关测试,则该行为也应由这些测试覆盖。

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

评估

技术栈
csharp, powershell
领域
tooling
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

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