Skip to content

Commit 8335c04

Browse files
Joel BennettJoel Bennett
authored andcommitted
Fix reversed null comparison around throws
1 parent a511ed4 commit 8335c04

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

HostIOInterceptor.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public override Dictionary<string, PSObject> Prompt(string caption,
152152
string message,
153153
Collection<FieldDescription> descriptions)
154154
{
155-
if (externalUI != null)
155+
if (externalUI == null)
156156
{
157157
throw new InvalidOperationException("Unable to prompt user in headless session");
158158
}
@@ -169,7 +169,7 @@ public override int PromptForChoice(string caption,
169169
Collection<ChoiceDescription> choices,
170170
int defaultChoice)
171171
{
172-
if (externalUI != null)
172+
if (externalUI == null)
173173
{
174174
throw new InvalidOperationException("Unable to prompt user for choice in headless session");
175175
}
@@ -186,7 +186,7 @@ public override PSCredential PromptForCredential(string caption,
186186
string userName,
187187
string targetName)
188188
{
189-
if (externalUI != null)
189+
if (externalUI == null)
190190
{
191191
throw new InvalidOperationException("Unable to prompt user for credential in headless session");
192192
}
@@ -205,7 +205,7 @@ public override PSCredential PromptForCredential(string caption,
205205
PSCredentialTypes allowedCredentialTypes,
206206
PSCredentialUIOptions options)
207207
{
208-
if (externalUI != null)
208+
if (externalUI == null)
209209
{
210210
throw new InvalidOperationException("Unable to prompt user for credential in headless session");
211211
}
@@ -224,7 +224,7 @@ public override PSCredential PromptForCredential(string caption,
224224

225225
public override string ReadLine()
226226
{
227-
if (externalUI != null)
227+
if (externalUI == null)
228228
{
229229
throw new InvalidOperationException("Unable to ReadLine from host in headless session");
230230
}
@@ -238,12 +238,11 @@ public override string ReadLine()
238238

239239
public override SecureString ReadLineAsSecureString()
240240
{
241-
if (externalUI != null)
241+
if (externalUI == null)
242242
{
243243
throw new InvalidOperationException("Unable to ReadLineAsSecureString from host in headless session");
244244
}
245245

246-
247246
return externalUI.ReadLineAsSecureString();
248247
}
249248

0 commit comments

Comments
 (0)