GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Run PowerShell class static methods in the correct Runspace/SessionState by daxian-dbw · Pull Request #4209 · PowerShell/PowerShell

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Jul 10, 2017

Copy link
Copy Markdown
Member

Fix #4001

Summary

When the same script file gets executed in multiple Runspaces, the RuntimeType generated from the powershell class defined in the file will be shared among those Runspaces. For different Runspaces, different SessionState should be used to run the static methods.

Fix

We use the SessionStateKeeper to query for the correct SessionState to use for a static method call.
We already use SessionStateKeeper to track the Runspace/SessionState where a PowerShell class is defined, and thus we can leverage this for the static method invocation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daxian-dbw
Run PowerShell class static methods in the correct Runspace/SessionState
8ecbd1e
@daxian-dbw Dongbo Wang (daxian-dbw) self-assigned this Jul 10, 2017
@daxian-dbw
Dongbo Wang (daxian-dbw) requested a review from Jason Shirk (lzybkr) July 10, 2017 18:39
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Jul 10, 2017
PaulHigin
Paul Higinbotham (PaulHigin) suggested changes Jul 10, 2017
View reviewed changes
Comment thread src/System.Management.Automation/engine/runtime/Operations/ClassOps.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/runtime/Operations/ClassOps.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/runtime/Operations/ClassOps.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Dongbo Wang (daxian-dbw) added 2 commits July 10, 2017 15:48
@daxian-dbw
Address review comments
11606c9
@daxian-dbw
Address review comments - 2
01fd93f
PaulHigin
Paul Higinbotham (PaulHigin) approved these changes Jul 11, 2017
View reviewed changes

@PaulHigin Paul Higinbotham (PaulHigin) left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daxian-dbw
Dongbo Wang (daxian-dbw) requested a review from Bruce Payette (BrucePay) July 12, 2017 23:06
@lzybkr
Fix typo in comment
7cb615f
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit c5f3a19 into PowerShell:master Jul 15, 2017
@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the class branch July 15, 2017 01:05
@daxian-dbw Dongbo Wang (daxian-dbw) mentioned this pull request Jun 24, 2019
WIP Move to runspace synchronizer from completions PowerShell/PowerShellEditorServices#980
Closed
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@daxian-dbw
Run PowerShell class static methods in the correct Runspace/SessionSt…
dd8b5b9
…ate (PowerShell#4209)

Summary
----------
When the same script file gets executed in multiple Runspaces, the RuntimeType generated from the powershell class defined in the file will be shared among those Runspaces. For different Runspaces, different SessionState should be used to run the static methods.

Fix
---
We use the `SessionStateKeeper` to query for the correct `SessionState` to use for a static method call.
We already use `SessionStateKeeper` to track the `Runspace/SessionState` where a PowerShell class is defined, and thus we can leverage this for the static method invocation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lzybkr Jason Shirk (lzybkr) Awaiting requested review from lzybkr
@BrucePay Bruce Payette (BrucePay) Awaiting requested review from BrucePay
1 more reviewer
@PaulHigin Paul Higinbotham (PaulHigin) PaulHigin approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@daxian-dbw Dongbo Wang (daxian-dbw)

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@daxian-dbw @PaulHigin @msftclas @lzybkr
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.