PowerShell / PowerShell/PowerShellEditorServices
Discussion: How should “evaluate” work?
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 767
- 派生
- 266
- 平均合并
- 3 天 16 小时
- 30 天内合并 PR
- 1
描述
Tagging @rjmholt and @andschwa
I discovered that the evaluate command has result hardcoded to ""
I don't necessarily think this is a bug since the output is supposed to be written to the host. However, in scenarios where we are strictly connected over NamedPipes, we have no way to gather the output.
My calling application already has a custom PSHost that sends output to the terminal over SignalR, so I tweaked the PSES code to use the host from my runspace instead of the one you guys created, and everything worked as expected. However, this means I need 2 websockets connections, one for JSONRPC and another for SignalR.
I have 3 ideas for fixing this and wanted you guys' take on it:
- Add -UseParentPSHost parameter to Start-EditorServices
This would be the easiest to implement. We already have the parent process's Host in the configuration object. Yes it will require my application to maintain a separate socket, but I'm doing that anyway.
I'd just need to ensure this host is also used when creating separate or out of process runspaces.
-
"Fix" the evaluate handler to return the result of the command so I can display that on my terminal. This gets hairy because then you have to ask whether you want the result to be the string output you'd see on the console or some sort of object representation that can easily be parsed by the calling application. For the sake of argument let's say the result should be terminal output string with colors encoded and all that. This can be accomplished by collecting all the output in the PSHost into a string and sending it along. However that means you get no output at all until execution completes which is undesirable for long running operations.
-
Make you guys' PSHost send window/logmessage events. I think this is the best way to do it, however I'd be concerned it could lead to duplicate output in the VS Code console as you guys are likely showing both stdout AND the window/logmessage event data.
I'd love to hear you guys' thoughts. Is there an easier way to do what I'm trying to do that I have perhaps overlooked?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 evaluate 命令及其 handler 开始,然后检查 Start-EditorServices 如何配置 PSHost 以及独立的或 out-of-process runspace。比较三种提议的输出路径——使用父 host、返回结果或 window/logmessage 事件——并定义一种支持 NamedPipes 且不会产生重复输出的统一行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, powershell
- 领域
- api, developer-experience
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 20/100