PowerShell / PowerShell/PowerShellEditorServices

Static methods in PSClasses are sometimes marshaled to disposed runspaces

Aperta
#483 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Issue-Bug
Lingua principale
C#
Stelle
767
Fork
266
Merge medio
3g 16h
PR unite (30g)
1

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con ReproSteps.zip e logs.zip, quindi segui i passaggi elencati Test-Class e Get-BoundRunspace tracciando la proprietà del runspace dei metodi statici tra First.ps1 e Second.ps1. Il lavoro è completato quando il comando ha esito positivo in entrambe le esecuzioni e Get-BoundRunspace segnala il runspace predefinito corrente invece di uno eliminato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
shell, vscode
Ambito
devtools, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.