Skip to content

hashtable formatting error #1530

Description

i've got a new problem with powershell formatting.
i upgraded to powershell-preview@2020.6.1 an hour or two before i noticed this problem.
it may have existed prior to the upgrade, but i never noticed it.
it's particularly scary because i didn't notice it for some time until my code started failing.

the attached zip has all the files described below plus a debug log.

the before .ps1 code is in hashtable-formatting_BEFORE.ps1

$AzureAD = (Get-Command -FullyQualifiedModule @{ModuleName = 'AzureAD'; ModuleVersion = '2.0.2.76' }).Name 
$AzureADPreview = (Get-Command -FullyQualifiedModule @{ModuleName = 'AzureADPreview'; ModuleVersion = '2.0.2.102' }).Name

and the after .ps1 code is in hashtable-formatting_AFTER.ps1

$AzureAD = (Get-Command -FullyQualifiedModule @{ModuleName = '2.0.2.76' }).Name 
$AzureADPreview = (Get-Command -FullyQualifiedModule @{ModuleName 'AzureADPreview'; ModuleVersion '2.0.2.102' }).Name

i tried to reproduce the problem in unaffected-hashtables.ps1 but the code here formatted correctly.
i can't explain why.

i duplicated this problem on two machines. the details are in machine-details.txt.

here's the interesting part:

machine 2 is basically win10 winver 2004 with vscode ootb plus powershell-preview@2020.6.1.
on machine 2, hashtable-formatting_BEFORE.ps1 formatted correctly.
then i copied my settings.json from machine 1 (win8.1) to machine 2.
when i reformatted hashtable-formatting_BEFORE.ps1 with the new settings.json, i got hashtable-formatting_AFTER.ps1.

so take a look at settings.json.

thanks folks

powershell-preview-hashtable-format-error.zip

Activity

  1. bergmeister commented on Jun 17, 2020

    @bergmeister
    Collaborator

    @elrod-johnson Thank you for taking the time to provide details. This is very likely caused by your setting powershell.codeFormatting.whitespaceBetweenParameters being set to true. This is a new setting that we recently added and its default is false. This issue has already been fixed as part of #1498 but is pending a patch release of PSScriptAnalyzer, which we plan to do in the next few weeks. In the meantime we suggest to set the setting value to its default value of false.
    FYI Rob Holt (@rjmholt) James Truher (@JamesWTruher) Sydney Smith (@SydneyhSmith)

  2. ghost closed this as completedon Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions