File tree 2 files changed +9
-1
lines changed
shell/AIShell.Integration
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -7,5 +7,10 @@ if ($null -eq $module -or $module.Version -lt [version]"2.4.2") {
7
7
throw " The PSReadLine v2.4.2-beta2 or higher is required for the AIShell module to work properly."
8
8
}
9
9
10
+ $runspace = $Host.Runspace
11
+ if ($null -eq $runspace ) {
12
+ throw " Failed to import the module because '`$ Host.Runspace' unexpectedly returns null.`n The host details:`n $ ( $Host | Out-String - Width 120 ) "
13
+ }
14
+
10
15
# # Create the channel singleton when loading the module.
11
- $null = [AIShell.Integration.Channel ]::CreateSingleton($host .Runspace , [Microsoft.PowerShell.PSConsoleReadLine ])
16
+ $null = [AIShell.Integration.Channel ]::CreateSingleton($runspace , [Microsoft.PowerShell.PSConsoleReadLine ])
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ public class Channel : IDisposable
31
31
32
32
private Channel ( Runspace runspace , Type psConsoleReadLineType )
33
33
{
34
+ ArgumentNullException . ThrowIfNull ( runspace ) ;
35
+ ArgumentNullException . ThrowIfNull ( psConsoleReadLineType ) ;
36
+
34
37
_runspace = runspace ;
35
38
_psrlType = psConsoleReadLineType ;
36
39
_connSetupWaitHandler = new ManualResetEvent ( false ) ;
You can’t perform that action at this time.
0 commit comments