Skip to content

#Requires with hashtable marked as invalid. #1314

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
omniomi opened this issue May 7, 2018 · 6 comments
Closed

#Requires with hashtable marked as invalid. #1314

omniomi opened this issue May 7, 2018 · 6 comments

Comments

@omniomi
Copy link
Contributor

omniomi commented May 7, 2018

System Details

  • Operating system name and version: Windows 10 1709
  • VS Code version: 1.23.0
  • PowerShell extension version: 1.7.0
PS X:\git\github\EditorSyntax> code -v

1.23.0
7c7da59c2333a1306c41e6e7b68d7f0caa7b3d45
x64

PS X:\git\github\EditorSyntax> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      7      0      0

PS X:\git\github\EditorSyntax> code --list-extensions --show-versions

[email protected]
[email protected]
[email protected]
[email protected]

PS X:\git\github\EditorSyntax> $PSVersionTable

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

Issue Description

When using #Requires -Modules with a hashtable (valid per https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires):

Requires -Modules PSWorkflow @{
  ModuleName="PSScheduledJob"
  ModuleVersion="1.0.0.0"
}

The hashtable is marked as invalid within VS Code:

Cannot process the #requires statement because it is not in the correct format.
The #requires statement must be in one of the following formats:
 "#requires -shellid <shellID>"
 "#requires -version <major.minor>"
 "#requires -psedition <edition>"
 "#requires -pssnapin <psSnapInName> [-version <major.minor>]"
 "#requires -modules <ModuleSpecification>"
 "#requires -runasadministrator"

hashtable-requires

@rkeithhill
Copy link
Contributor

What version of PSSA is getting loaded into the integrated console. You should be able to check this with:

(Get-Runspace 4).CreatePipeline("gmo psscriptanalyzer").Invoke()

@omniomi
Copy link
Contributor Author

omniomi commented May 7, 2018

@rkeithhill 1.16.1

@rkeithhill
Copy link
Contributor

OK, that message is coming from PSScriptAnalyzer but in this case it is correct. A #Requires is a special line comment. It can't span multiple lines. Try using this instead:

#Requires -Modules PSWorkflow,@{ModuleName="PSScheduledJob"; ModuleVersion="1.0.0.0"}

@omniomi
Copy link
Contributor Author

omniomi commented May 8, 2018

@rkeithhill, that was a copy paste directly from about_requires. If it cannot be multi-line I will submit a documentation issue to Microsoft.

@rkeithhill
Copy link
Contributor

I'm ~90% sure that's a doc bug.

@omniomi
Copy link
Contributor Author

omniomi commented May 8, 2018

@rkeithhill, fair enough. I have honestly never tried. Just working on the EditorSyntax repo. Will submit a doc bug report.

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

2 participants