Script Content Triggers unhandled Newtonsoft.Json.JsonSerializationException
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- csharp, powershell, vscode
- Domaine
- developer-experience, devtools
Piste de recherche
Commencez par reproduire l’échec avec l’extrait PowerShell fourni et examinez PowerShellEditorServices-14896.log, StartEditorServices-14896.log et vscode-powershell.log. Suivez l’échec de sérialisation non géré dans PowerShell Editor Services ; le travail est terminé lorsque l’exception est gérée et que l’énumération de Command Explorer ainsi qu’IntelliSense continuent de fonctionner.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- C#
- Étoiles
- 767
- Forks
- 266
- Merge moyen
- 3 j 16 h
- PR mergées (30 j)
- 1
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de PowerShell/PowerShellEditorServices
-
[Bug] None of the string overloads of `EditorExtensionServiceProvider.GetService()` work on .NET. Ouverte
PowerShell/PowerShellEditorServices#2331 · 1 réaction · 2 personnes assignées ·
-
Area-Language Server Issue-Enhancement
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
PowerShell/PowerShellEditorServices#2315 · 1 commentaire ·
-
Area-Debugging Issue-Enhancement
PowerShell/PowerShellEditorServices#2294 · 1 réaction · 2 personnes assignées ·
-
Issue-Bug Needs: Triage
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
PowerShell/PowerShellEditorServices#2293 · 1 commentaire ·
-
PowerShell/PowerShellEditorServices#2282 · 1 commentaire · 1 réaction · 2 personnes assignées ·
Toutes les issues de PowerShell/PowerShellEditorServices
Issues similaires
-
effort:S P3 refactor
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
nightscout/nocturne#1532 ·
-
core dependencies
Difficulté 1/5 Moins d'une heure Accessibilité débutants 80/100
-
documentation
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
C#/.NET Roslyn LSP Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
-
Suspicious code fragments Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
DotNetNext/SqlSugar#1458 ·