Skip to content

Suppress platform-specific parse errors #301

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

Open
JasonMorgan opened this issue Sep 21, 2016 · 8 comments
Open

Suppress platform-specific parse errors #301

JasonMorgan opened this issue Sep 21, 2016 · 8 comments
Labels
Area-Script Analysis Issue-Enhancement A feature request (enhancement).

Comments

@JasonMorgan
Copy link

Please fill in these details so that we can help you!

System Details

  • Operating system name and version: Mac OS
  • VS Code version: 1.5.2
  • PowerShell extension version: 6 alpha
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      Core
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.9
CLRVersion
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

workflow statements present an error and I can't seem to suppress it. I understand workflow won't run but I want to author them without an error. It'd be nice if I had the option to suppress or ignore it.

@mrvladis
Copy link

mrvladis commented Nov 1, 2017

Have the same issue ;(

@mmclane
Copy link

mmclane commented Jul 19, 2018

Me too

@rjmholt
Copy link
Contributor

rjmholt commented Jul 19, 2018

Hi @JasonMorgan, @mrvladis, @mmclane would you be able to provide an example of:

  • The script (including the workflow) you're writing in the editor
  • The error you're getting (what it says, how you're getting it, where it's coming from, if it's a crash)

The difficulty I see here is that not only will a workflow not run in PowerShell Core 6, but it won't even parse (i.e. PowerShell Core 6 itself will refuse to parse any input with a workflow in it). Since the extension relies on PowerShell to parse and provide completions for scripts, enabling workflows may involve disabling a good deal of extension functionality.

@rjmholt rjmholt added Issue-Enhancement A feature request (enhancement). Issue-Discussion Let's talk about it. Area-General labels Jul 19, 2018
@mmclane
Copy link

mmclane commented Jul 19, 2018

I haven't done a lot with workflows but in working with Azure Automation I find myself needing to work with them. Not that I will be running them on my local machine. Instead I am writing a template that terraform renders into a working script. I change the langues from Plain Text to Powershell so that I can get the syntax highlighting and what not, but its all marked as red because of the workflow statements.

It doesn't matter what the script is, as soon as I wrap it in a workflow statement I get a problem and everything in that statement is marked as red.

image

What would be better is if it marked the workflow statement as red but not everything inside it. What would be better still is if I could mark that problem to be ignored. What I could live with is knowing how to disable [PowerShell] problems from being evaluated on that file.

Make sense?

@mmclane
Copy link

mmclane commented Jul 19, 2018

I am using Code version 1.25.1
PowerShell extension version 1.8.1

Name Value


PSVersion 6.0.2
PSEdition Core
GitCommitId v6.0.2
OS Darwin 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

@rkeithhill
Copy link
Contributor

You can switch to a "Windows PowerShell" session if you're on Windows or disable code analysis since it is PSScriptAnalyzer that generates that (parse) error e.g.:

07-19 08:44:39 2> Invoke-ScriptAnalyzer .\workflow.ps1
Invoke-ScriptAnalyzer : Parse error in file C:\Users\Keith\workflow.ps1:  Workflow is not supported in PowerShell Core at line 1 column 1.

Open up your user or workspace settings and add this setting:

"powershell.scriptAnalysis.enable": false

Short of disabling script analysis, there is nothing this extension can do. There is not even a PSSA rule we can ignore since it is a "parse" error. I suggest filing an issue with PSSA https://github.com/powershell/scriptanalyzer.

@rjmholt
Copy link
Contributor

rjmholt commented Jul 19, 2018

Ah cool! Yeah, I saw you're on macOS, and it does make sense that you might want to develop for scenarios off-platform.

Like @rkeithhill says, disabling analysis is the best workaround for now. Another thing worth noting is that there is an (old) issue open for turning parse errors into something more ignorable: PowerShell/PSScriptAnalyzer#264. I know I've discussed this with @JamesWTruher as well.

@rjmholt rjmholt changed the title ignore workflow errors in Powershell Core Suppress platform-specific parse errors May 24, 2019
@SydneyhSmith SydneyhSmith removed the Issue-Discussion Let's talk about it. label May 28, 2019
@yadirhb
Copy link

yadirhb commented Sep 20, 2021

Is there a workaround this yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Script Analysis Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

7 participants