PowerShell / PowerShell/PowerShellEditorServices

Static methods in PSClasses are sometimes marshaled to disposed runspaces

Ouverte
#483 0 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Issue-Bug
Langage dominant
C#
Étoiles
767
Forks
266
Merge moyen
3 j 16 h
PR mergées (30 j)
1

Description

logs.zip
ReproSteps.zip

Steps to reproduce

  1. Download an extract in the included example.

  2. Move the folder "Example" into your PSModulePath

  3. Open the folder "Example2" in VSCode

  4. Open the file "First.ps1" and run the command Test-Class (this is a function from "Example")

  5. (Optional) Run the command included in "First.ps1", this will show the runspace the static method is currently bound to.

  6. Open the file "Second.ps1" and run the command Test-Class again.

  7. (Optional) Run Get-BoundRunspace again.

Expected results

The command Test-Class to output Test was successful both times, and Get-BoundRunspace to return the current default runspace both times.

Actual results

The command Test-Class works the first time, but after the second file is opened it throws a null reference exception and Get-BoundRunspace shows a runspace that is no longer open.

Notes

The steps are exact, if Test-Class isn't ran before switching files, or if "Second.ps1" is loaded first, it won't happen.

Although the steps may seem strange, this happens to me frequently if my module is in the module path, and makes static methods in classes not viable. My assumption is that PSES creates a runspace for PSSA which then loads the module causing that execution context to be the new owner. The runspace is then disposed, but the owner doesn't revert.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par ReproSteps.zip et logs.zip, puis suivez les étapes Test-Class et Get-BoundRunspace indiquées tout en retraçant la propriété du runspace des méthodes statiques dans First.ps1 et Second.ps1. C’est terminé lorsque la commande réussit lors des deux exécutions et que Get-BoundRunspace signale le runspace par défaut actuel plutôt qu’un runspace supprimé.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
shell, vscode
Domaine
devtools, tooling
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.