Write event on configurationDone for attach requests
還沒有人認領這個 Issue。
評估
研究方向
先追蹤 PowerShell Editor Services 的 attach 流程,以及對 debug adapter protocol 的 configurationDone 請求的處理,接著檢視 issue 中描述的 PowerShell remoting 事件 API。當 attach 用戶端能在中斷點設定完成後等待一個已知的 PSES.ConfigurationDone 事件時,即表示完成;先判斷這是否需要變更 PowerShell 本身,還是只需要變更 PSES。
由索引模型根據 Issue 內容生成。
描述
Prerequisites
- I have written a descriptive issue title.
- I have searched all issues to ensure it has not already been requested.
Summary
On attach scenarios, it is not possible to wait for all the breakpoints set by the client to be set in the remote runspace. A client could have something like
$originalRunspaces = Get-Runspace
Read-Host -Prompt "Please attach to process $pid with runspace $([Runspce]::DefaultRunspace.Id)"
# Waits for VSCode to attach to runspace, an extra runspace will be created by
# Enter-PSHostProcess
while ($true) {
$newRunspace = Get-Runspace | Where-Object { $_.Id -notin $runspaces.Id } | Select-Object -First 1
if ($newRunspace) {
break
}
Start-Sleep -Milliseconds 300
}
& .\script.ps1
But this only checks that PSES has attached to the named pipe. It won't wait for PSES to have called Debug-Runspace on the target runspace and more importantly any breakpoints inside script.ps1 to be set. It's also error prone if you cannot control when the attach actually happens as the additional runspace check could have occurred before the first Get-Runspace call.
What would be ideal is for a well known event to be created by PSES when configurationDone was received so that the client only had to do
# Attach to this runspace somehow
$e = Wait-Event -SourceIdentifier PSES.ConfigurationDone -Timeout 30
if ($e) {
$e | Remove-Event
}
else {
throw "Timed out waiting for attach event"
}
Proposed Design
My proposal requires some changes to PowerShell itself but I wanted to see if the general idea was acceptable before trying to propose the change there. The benefit of using an event is that no custom functions needed to be loaded, and subsequently checked by the code, and Wait-Event has a simple timeout operation.
Ultimately what needs to happen is for PowerShell to expose a __New-Event command, similar to the new __Set-PSBreakpoint commands, that is treated specially by the PSRemoting server. This would be able to do the following but without having to spin up a new pipeline.
$runspace = Get-Runspace -Id $runspaceId
$runspace.Events.GenerateEvent($SourceId, $Sender, $EventArgs, $EventData)
We cannot just have PSES run this script or call New-Event directly as the runspace pipeline is busy running Debug-Runspace. The only time it can run commands is if the caller ran Wait-Debugger which is not ideal as it will pause the execution and require the client to continue on manually.
An alternative that I haven't tried out yet is to delay Debug-Runspace until after configurationDone is sent. This would allow both the breakpoints and event to be manually emited as commands on the runspace specified without having to block the pipeline with Debug-Runspace. I am not sure if that will be possible though but it could be an option that doesn't require any changes to PowerShell itself.
- 主要語言
- C#
- 星號
- 767
- 分支
- 266
- 平均合併
- 3 天 16 小時
- 30 天內合併 PR
- 1
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
PowerShell/PowerShellEditorServices 的其他 Issue
-
[Bug] None of the string overloads of `EditorExtensionServiceProvider.GetService()` work on .NET. 未關閉
PowerShell/PowerShellEditorServices#2331 · 1 個 reaction · 已指派 2 人 ·
-
Area-Language Server Issue-Enhancement
難度 4/5 3-5 天 新手友好度 48/100
PowerShell/PowerShellEditorServices#2315 · 1 則留言 ·
-
Area-Debugging Issue-Enhancement
PowerShell/PowerShellEditorServices#2294 · 1 個 reaction · 已指派 2 人 ·
-
Issue-Bug Needs: Triage
難度 4/5 3-5 天 新手友好度 48/100
PowerShell/PowerShellEditorServices#2293 · 1 則留言 ·
-
PowerShell/PowerShellEditorServices#2282 · 1 則留言 · 1 個 reaction · 已指派 2 人 ·
查看 PowerShell/PowerShellEditorServices 的全部 Issue
相似的 Issue
-
effort:S P3 refactor
難度 2/5 1-3 小時 新手友好度 75/100
nightscout/nocturne#1532 ·
-
core dependencies
難度 1/5 1 小時以內 新手友好度 80/100
-
documentation
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 75/100
DotNetNext/SqlSugar#1458 ·