PowerShell / PSScriptAnalyzer

Download ScriptAnalyzer from PowerShellGallery
https://www.powershellgallery.com/packages/PSScriptAnalyzer/
MIT License
1.87k stars 378 forks source link

UseCorrectCasing removes `<module>\` from `<module>\<cmdlet>` in vscode-powershell #2023

Open o-l-a-v opened 3 months ago

o-l-a-v commented 3 months ago

Steps to reproduce

This does not happen if you have a file only containing:

Az.Monitor\Get-AzDataCollectionRuleAssociation

Thus:

  1. VSCode settings.json contains: "powershell.codeFormatting.useCorrectCasing": true.

  2. Create temp.ps1 with following content:

    Write-Information -MessageData 'Adding associations.'
    $DCRs | ForEach-Object -ThrottleLimit $DCRs.'Count' -Parallel {
        $null = Add-Member -InputObject $_ -MemberType 'NoteProperty' -Force -Name 'associations' -Value (
            [array](
                Az.Monitor\Get-AzDataCollectionRuleAssociation -SubscriptionId $_.'subscriptionId' `
                    -ResourceGroupName $_.'resourceGroup' -DataCollectionRuleName $_.'name'
            )
        )
    } 6>$null
  3. Save. The content becomes:

    Write-Information -MessageData 'Adding associations.'
    $DCRs | ForEach-Object -ThrottleLimit $DCRs.'Count' -Parallel {
        $null = Add-Member -InputObject $_ -MemberType 'NoteProperty' -Force -Name 'associations' -Value (
            [array](
                Get-AzDataCollectionRuleAssociation -SubscriptionId $_.'subscriptionId' `
                    -ResourceGroupName $_.'resourceGroup' -DataCollectionRuleName $_.'name'
            )
        )
    } 6>$null

Expected behavior

Content should not change.

Actual behavior

Az.Monitor\ gets stripped.

Environment data