Skip to content

Commit e2629c6

Browse files
committed
Refactor.
1 parent 79f2b5d commit e2629c6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

PSql.Tests/Tests.Support/RunspaceScope.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace PSql.Tests;
77

8-
internal class RunspaceScope : IDisposable
8+
internal sealed class RunspaceScope : IDisposable
99
{
1010
private readonly Runspace _oldRunspace;
1111
private readonly PowerShell _shell;
@@ -16,16 +16,18 @@ public RunspaceScope(InitialSessionState state)
1616
public RunspaceScope()
1717
: this(PowerShell.Create()) { }
1818

19-
protected RunspaceScope(PowerShell shell)
19+
private RunspaceScope(PowerShell shell)
2020
{
2121
_oldRunspace = Runspace.DefaultRunspace;
2222
_shell = shell;
2323

24+
// Set thread-static default runspace
2425
Runspace.DefaultRunspace = shell.Runspace;
2526
}
2627

2728
void IDisposable.Dispose()
2829
{
30+
// Restore thread-static default runspace
2931
Runspace.DefaultRunspace = _oldRunspace;
3032

3133
_shell.Dispose();

0 commit comments

Comments
 (0)