Currently logic for variables has problems. On top-level objects, you treat variables as strings with $ character to make sure when a user checks the object they are aware it's a variable, not just getting $null. This works great for variables such as "$MyVar", "$Credentials" and so on. But then for nested objects, you no longer treat variables as variables. In the case of $True/$False you don't leave them as a string with "$True" but you explicitly convert them to bool. For Arrays, you leave them as strings again.
This means you have inconsistency and you treat them differently. This PR improves this logic:
If it's $true or $false it explicitly uses bool
If it's not $true or $false it uses your existing logic and makes them a string with $ character
It keeps it consistent across Root Object, CimInstance and Arrays.
I have also applied the same logic as $true/$false to $null. For me it makes sense, but feel free to decide on that.
Fixes NoisyTypes for faster code parsing (although not much difference). Was unused variables before. NewLIne is important so I left it as is.
Fixes NoisyOperators - was working fine, but PSScriptAnalyzer complained as unused variable. I've explicitly defined it in functions and passed as parameter. Alternative was $Script:$NoisyOperators but thought the second one was a bit weird as it appeared from thin air
Currently logic for variables has problems. On top-level objects, you treat variables as strings with $ character to make sure when a user checks the object they are aware it's a variable, not just getting
$null
. This works great for variables such as "$MyVar", "$Credentials" and so on. But then for nested objects, you no longer treat variables as variables. In the case of$True/$False
you don't leave them as a string with "$True" but you explicitly convert them to bool. For Arrays, you leave them as strings again.This means you have inconsistency and you treat them differently. This PR improves this logic:
It keeps it consistent across Root Object, CimInstance and Arrays.
NoisyTypes
for faster code parsing (although not much difference). Was unused variables before. NewLIne is important so I left it as is.NoisyOperators
- was working fine, but PSScriptAnalyzer complained as unused variable. I've explicitly defined it in functions and passed as parameter. Alternative was $Script:$NoisyOperators but thought the second one was a bit weird as it appeared from thin air