Open BalassaMarton opened 8 months ago
Likely an issue in scriptanalyzer, we can see if we can reproduce and an issue would need to be opened there.
As a workaround, have you considered using splatting syntax rather than backticks?
function Dummy($ParameterObject) { $ParameterObject.Property }
$dummyParam = @{
ParameterObject = @{
Property = 'value'
}
}
Dummy @dummyParam
As a workaround, have you considered using splatting syntax
That was just an example minimal repro case. In reality I'm calling Azure PowerShell functions having all sorts of parameters.
@BalassaMarton even in that case I would strongly recommend splatting as you can have conditional parameters, and overall make the invocation much more structured than using backticks with parameters.
Looks to me like the issue is at the PSScriptAnalyzer level, as shown here:
gmo psscriptanalyzer
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 1.22.0 psscriptanalyzer {Get-ScriptAnalyzerRule, Invoke-Formatter, Invoke…
So you will need to open the issue in scriptanalyzer and, when fixed and version released, will work its way to this repo to be fixed (you could also install an early release of psscriptanalyzer and the extension can use that)
EDIT: Sorry I initially misread the scriptanalyzer result EDIT2: Nope, I did in fact read it correctly.
Prerequisites
Summary
Formatting multi-line function calls with hashtable parameters produces incorrect indentation of the function call.
Example script:
After formatting, the script looks like this:
Notice how the indentation of the function call is off after the
-ParameterObject
argument.PowerShell Version
Visual Studio Code Version
Extension Version
Steps to Reproduce
.ps1
extension}
Dummy ` -ParameterObject @{ Property = "value" }