You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As someone who writes a lot of C code and is a big fan of clang-format's AlignConsecutiveAssignments, I'm also a big fan of Invoke-Formatter's PSAlignAssignmentStatement option. There have been a couple of previous requests (#1029, #1385) to extend this to cover all assignments; personally I'd like to have the option, but the arguments against are valid.
That said, PSAlignAssignmentStatement currently applies to both hashtables and DSC configuration statements, but it does not apply to enum type declarations; these are syntactically similar to hashtables and I was surprised to find that it doesn't apply already. On top of that, enum declarations like this one:
is much nicer to look at, easier to read, and has a +1 dopamine bonus instead.
In some cases i've converted from an enum over to a PSCustomObject just to get this formatting, which comes with its own problems and loss of methods/strong typing.
I would like PSAlignAssignmentStatement to apply to enum types as well as the existing hashtable and DSC configuration types. Due to the syntactic similarity, ISTM it would be in line with the existing hashtable/DSC behaviour.
What is the latest version of PSScriptAnalyzer at the point of writing
Summary of the new feature
As someone who writes a lot of C code and is a big fan of clang-format's
AlignConsecutiveAssignments
, I'm also a big fan ofInvoke-Formatter
's PSAlignAssignmentStatement option. There have been a couple of previous requests (#1029, #1385) to extend this to cover all assignments; personally I'd like to have the option, but the arguments against are valid.That said, PSAlignAssignmentStatement currently applies to both hashtables and DSC configuration statements, but it does not apply to
enum
type declarations; these are syntactically similar to hashtables and I was surprised to find that it doesn't apply already. On top of that,enum
declarations like this one:cause me to take 1d4 psychic damage, while the aligned version:
is much nicer to look at, easier to read, and has a +1 dopamine bonus instead.
In some cases i've converted from an
enum
over to aPSCustomObject
just to get this formatting, which comes with its own problems and loss of methods/strong typing.Proposed technical implementation details (optional)
I would like PSAlignAssignmentStatement to apply to enum types as well as the existing hashtable and DSC configuration types. Due to the syntactic similarity, ISTM it would be in line with the existing hashtable/DSC behaviour.
What is the latest version of PSScriptAnalyzer at the point of writing
v2022.10.0
The text was updated successfully, but these errors were encountered: