PowerShell / PowerShell/PowerShellEditorServices

Script Content Triggers unhandled Newtonsoft.Json.JsonSerializationException

Đang mở
#2,165 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Issue-Bug Needs: Triage
Ngôn ngữ chính
C#
Star
767
Fork
266
Merge trung bình
3 ngày 16 giờ
Pull request đã merge (30 ngày)
1

Mô tả

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:

  1. Insert aforementioned code snippet into any user defined PowerShell script.
  2. Make sure the script can be found by the PowerShellEditorServices by including its fully qualified path (not file name) in the path environment variable.
  3. Open Visual Studio Code (with the PowerShell for VS Code extension (by Microsoft) installed.
  4. 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
  5. 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lỗi với đoạn mã PowerShell được cung cấp và xem xét PowerShellEditorServices-14896.log, StartEditorServices-14896.log và vscode-powershell.log. Truy vết lỗi tuần tự hóa chưa được xử lý trong PowerShell Editor Services; công việc được xem là hoàn tất khi ngoại lệ được xử lý và việc liệt kê của Command Explorer cùng IntelliSense tiếp tục hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, powershell, vscode
Lĩnh vực
developer-experience, devtools
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.