We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 79f2b5d commit e2629c6Copy full SHA for e2629c6
1 file changed
PSql.Tests/Tests.Support/RunspaceScope.cs
@@ -5,7 +5,7 @@
5
6
namespace PSql.Tests;
7
8
-internal class RunspaceScope : IDisposable
+internal sealed class RunspaceScope : IDisposable
9
{
10
private readonly Runspace _oldRunspace;
11
private readonly PowerShell _shell;
@@ -16,16 +16,18 @@ public RunspaceScope(InitialSessionState state)
16
public RunspaceScope()
17
: this(PowerShell.Create()) { }
18
19
- protected RunspaceScope(PowerShell shell)
+ private RunspaceScope(PowerShell shell)
20
21
_oldRunspace = Runspace.DefaultRunspace;
22
_shell = shell;
23
24
+ // Set thread-static default runspace
25
Runspace.DefaultRunspace = shell.Runspace;
26
}
27
28
void IDisposable.Dispose()
29
30
+ // Restore thread-static default runspace
31
Runspace.DefaultRunspace = _oldRunspace;
32
33
_shell.Dispose();
0 commit comments