PowerShell / PowerShell/PowerShellEditorServices

Discussion: How should “evaluate” work?

オープン
#1,515 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Issue-Discussion
主要言語
C#
スター
767
フォーク
266
平均マージ
3日 16時間
マージ済み PR(30日)
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:

  1. 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.

  1. "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.

  2. 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?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

evaluate コマンドとその handler から始め、次に Start-EditorServices が PSHost と分離された、または out-of-process の runspace をどのように構成するかを調べます。提案されている 3 つの出力経路—親ホストの使用、返される結果、または window/logmessage イベント—を比較し、出力を重複させずに NamedPipes をサポートする合意済みの動作を定義します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp, powershell
領域
api, developer-experience
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。