Script Content Triggers unhandled Newtonsoft.Json.JsonSerializationException
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- csharp, powershell, vscode
研究方向
首先使用提供的 PowerShell 程式碼片段重現故障,並檢查 PowerShellEditorServices-14896.log、StartEditorServices-14896.log 和 vscode-powershell.log。追蹤 PowerShell Editor Services 中未處理的序列化故障;當例外狀況得到處理,且 Command Explorer 列舉和 IntelliSense 繼續正常運作時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
- I have verified that I am using the latest version of PowerShell Editor Services.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
When the following code snippet is encountered in a user created PowerShell script, and the script's path is in the environment path variable, PowerShellEditorServices fails. This appears to be caused by a Newtonsoft.Json.JsonSerializationException (For additional details, see the included PowerShellEditorServices-14896.log file included below).
Because the PowerShellEditorServices is used by the PowerShell Extension for Visual Studio Code, both the extension's Command Explorer and Intellisense stop working when this exception occurs. Ideally, I feel the PowerShellEditorServices should gracefully handle and report the exception and continue running.
param (
[Parameter(Mandatory=$false)]
[ValidateScript({
if ($_ -is [int] -and $_ -ge 0) {
$true
} else {
throw "The input argument be a positive integer or zero."
}
})]
[int]$DaysBack = 0 # Default value is 0
)
PowerShell Version
PS ~> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.3
PSEdition Core
GitCommitId 7.4.3
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Editor Version
Installed PowerShell Extension for Visual Studio Code.
PowerShell Editor Services Version
N/A
Steps to Reproduce
In Windows 11:
- Insert aforementioned code snippet into any user defined PowerShell script.
- Make sure the script can be found by the PowerShellEditorServices by including its fully qualified path (not file name) in the path environment variable.
- Open Visual Studio Code (with the PowerShell for VS Code extension (by Microsoft) installed.
- Click on the PowerShell icon in the left panel, to show the Command Explorer. (You may need to enable this extension's setting: PowerShell>SideBar: Command Explorer Visibility
- The Command Explorer will fail to enumerate and Intellisense will stop working for PowerShell scripts.
Visuals
No response
Logs
PowerShellEditorServices-14896.log
StartEditorServices-14896.log
vscode-powershell.log
- 主要語言
- C#
- 星號
- 772
- 分支
- 268
- 平均合併
- 3 天 16 小時
- 30 天內合併 PR
- 1
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
PowerShell/PowerShellEditorServices 的其他 Issue
-
[Bug] None of the string overloads of `EditorExtensionServiceProvider.GetService()` work on .NET.可能重新可做 @andyleejordan 於 101 天前認領,目前沒有進行中的 PR。 未關閉
PowerShell/PowerShellEditorServices#2331 · 1 個 reaction · 已指派 2 人 ·
-
Area-Language Server Issue-Enhancement
難度 4/5 3-5 天 新手友好度 48/100
PowerShell/PowerShellEditorServices#2315 · 1 則留言 ·
-
Improve Constrained Runspace Debug Experience可能已有人在做 @JustinGrote 於 125 天前認領。 未關閉Area-Debugging Issue-Enhancement
PowerShell/PowerShellEditorServices#2294 · 1 個 reaction · 已指派 2 人 ·
-
Issue-Bug Needs: Triage
難度 4/5 3-5 天 新手友好度 48/100
PowerShell/PowerShellEditorServices#2293 · 1 則留言 ·
-
Document outline drops child variables when a function/filter reuses a variable name declared earlier (scope-blind declaration dedup)可能已有人在做 @JustinGrote 於 152 天前認領。 未關閉
PowerShell/PowerShellEditorServices#2282 · 1 則留言 · 1 個 reaction · 已指派 2 人 ·
查看 PowerShell/PowerShellEditorServices 的全部 Issue
相似的 Issue
-
[Doc Gap] Document new --enable-public-network-access breaking change for azurebackup vault create未關閉copilot documentation
難度 2/5 1-3 小時 新手友好度 86/100
維護者通常 1 天內回覆
-
area-dashboard
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
0 - Backlog Bug
難度 2/5 1-3 小時 新手友好度 72/100
BrighterCommand/Brighter#4539 ·
維護者通常 1 天內回覆
-
triage
難度 2/5 1-3 小時 新手友好度 78/100
-
area-networking
難度 2/5 1-3 小時 新手友好度 68/100
dotnet/aspnetcore#69671 · 1 則留言 ·
維護者通常 1 天內回覆