Skip to content

Behavior when prompted for mandatory bool parameter is different in PowerShell Integrated Console #1042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cormacpayne opened this issue Oct 3, 2017 · 2 comments

Comments

@cormacpayne
Copy link

System Details

  • Operating system name and version:
  • VS Code version:
  • PowerShell extension version:
  • Output from $PSVersionTable:
Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:

PS C:\Users\corm\Documents> code -v
1.16.1
27492b6bf3acb0775d82d2f87b25a93490673c6d

PS C:\Users\corm\Documents> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      4      1      0

PS C:\Users\corm\Documents> code --list-extensions --show-versions
donjayamanne.python@0.7.0
formulahendry.code-runner@0.7.2
gerane.Theme-Monokai-Contrast@0.0.2
idleberg.hopscotch@0.2.0
ms-vscode.cpptools@0.13.0
ms-vscode.csharp@1.12.1
ms-vscode.PowerShell@1.4.3
zhuangtongfa.Material-theme@2.10.12

PS C:\Users\corm\Documents> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.608
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.608
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I have the following in a temp.ps1 script:

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [bool]$Foo
)

$Foo

When I run .\temp.ps1 with no parameters, I get prompted to provided a value for Foo, which I immediately press ENTER, assigning False to Foo. When running in the powershell tab in VS Code, I see the following:

corm@CORMAC : ~\Documents : 10/3/2017 4:37:58 PM :
> .\temp.ps1

cmdlet temp.ps1 at command pipeline position 1
Supply values for the following parameters:
Foo:
False

However, when I run the same thing in the PowerShell Integrated Console tab in VS Code, I see the following:

PS C:\Users\corm\Documents> .\temp.ps1
cmdlet temp.ps1 at command pipeline position 1
Supply values for the following parameters:
Foo:
C:\Users\corm\Documents\temp.ps1 : Cannot process argument transformation on parameter 'Foo'. Cannot convert value "" to type "System.Boolean". Boolean parameters accept only Boolean values and
numbers, such as $True, $False, 1 or 0.
At line:1 char:1
+ .\temp.ps1
+ ~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [temp.ps1], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,temp.ps1

I may be unaware of the underlying difference(s) between powershell and PowerShell Integrated Console, so please let me know if this is expected behavior 😃

Attached Logs

See above.

@rjmholt
Copy link
Contributor

rjmholt commented Dec 3, 2018

This is likely because we had to write our own readline for the integrated console. I imagine this will be fixed by #535.

@SydneyhSmith
Copy link
Collaborator

Closing as PSReadLine is now available in the PowerShell Preview extension, tracking that PSReadLine is not available in the main PowerShell Extension here #1793

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants