Skip to content
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

Prevent Process conversion to Get-Process #1514

Closed
PrzemyslawKlys opened this issue May 29, 2020 · 6 comments
Closed

Prevent Process conversion to Get-Process #1514

PrzemyslawKlys opened this issue May 29, 2020 · 6 comments

Comments

@PrzemyslawKlys
Copy link
Contributor

This is a bit of non-standard request - I often get into a situation where for some reason Process gets converted to Get-Process and breaks a function (it should be Begin / Process / End) that I notice way too late. I am not sure when it happens but with formatting on save or just formatting on demand it does happen and can cause issues. Would it be possible to make a hard exception for Process where it doesn't get converted from alias to function name?

@ghost ghost added the Needs: Triage 🔍 label May 29, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Jun 2, 2020

@PrzemyslawKlys could you provide an example script in which this is happening?

@SydneyhSmith
Copy link
Collaborator

@PrzemyslawKlys it would also be great to know the output of:
gmo PSScriptAnalyzer

@PrzemyslawKlys
Copy link
Contributor Author

Right now I have only latest. I used to have multiple 0.18.x.




    Directory: C:\Users\przemyslaw.klys\Documents\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.19.0     PSScriptAnalyzer                    {Get-ScriptAnalyzerRule, Invoke-ScriptAnalyzer, Invoke-Formatter}


    Directory: C:\Users\przemyslaw.klys\.vscode\extensions\ms-vscode.powershell-preview-2020.6.0\modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.19.0     PSScriptAnalyzer                    {Get-ScriptAnalyzerRule, Invoke-ScriptAnalyzer, Invoke-Formatter}

Usually, I have code like this:

function Test-Me {
    [cmdletBinding()]
    param(

    )
    Begin {

    }
    Process {

    }
    End {

    }
}

Having said that - it doesn't just automatically happen. It will randomly insert Get-Process instead of Process - I am not sure when that happens, and under what conditions. I just noticed it couple of times and I can't reproduce it on demand.

@ghost
Copy link

ghost commented Jun 17, 2020

Closing due to inactivity

@bergmeister
Copy link
Collaborator

bergmeister commented Jun 17, 2020

I think this is actually a duplicate of #1402 and the learnings from that other issue is that it only happens when there is invalid syntax (both at either parse or runtime). What probably happens as well is that this allows time for a rogue entry to make its way into the cache and once it's in the cache it will always stay there until the next restart of the integrated terminal.
Re-opening it temporarily to see if we get more information or thoughts but given that process is the only exception where the implicit Get- aliasing does not apply since process is a keyword in the first place, therefore I think we should just hard-code process to be excluded in the Get- aliasing check to avoid that problem from happening in the first place.

@bergmeister bergmeister reopened this Jun 17, 2020
@ghost
Copy link

ghost commented Jun 18, 2020

This issue has been marked as duplicate and has not had any activity for 1 day. It will be closed for housekeeping purposes.

@ghost ghost closed this as completed Jun 18, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants