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
get the session variable value if it is not $null or ''
get the environment value if it is not $null or ''
get the specified default if it is not $null
error
Note that '' is still allowed as the default value. It is up to a developer to specify it and avoid errors or omit it and allow errors.
Thoughts
(1) Properties are mostly strings because one of their sources is environment variables which are strings.
(2) PowerShell assigns empty strings as default values of strongly typed string variables. Example: default script parameters and variables declared as [string]. Even assigning $null explicitly results in the empty string actually assigned. Thus, empty strings should be treated as not defined. Otherwise, we have to drop useful strong typing, see #59 (comment)
(3) The proposed behavior aligns with MSBuild properties. Example: in MSBuild Condition="'$(MyProperty)' == ''" not defined $(MyProperty) (i.e. currently $null in PowerShell properties) and an empty string are treaded in the same way, "not defined".
Caveat
In theory, such a change may break some code. But empty strings are unlikely used as meaningful properties in practice. So we are not going to treat this as a major change.
The text was updated successfully, but these errors were encountered:
Current behavior
Proposed behavior
Note that '' is still allowed as the default value. It is up to a developer to specify it and avoid errors or omit it and allow errors.
Thoughts
(1) Properties are mostly strings because one of their sources is environment variables which are strings.
(2) PowerShell assigns empty strings as default values of strongly typed string variables. Example: default script parameters and variables declared as
[string]
. Even assigning $null explicitly results in the empty string actually assigned. Thus, empty strings should be treated as not defined. Otherwise, we have to drop useful strong typing, see #59 (comment)(3) The proposed behavior aligns with MSBuild properties. Example: in MSBuild
Condition="'$(MyProperty)' == ''"
not defined$(MyProperty)
(i.e. currently $null in PowerShell properties) and an empty string are treaded in the same way, "not defined".Caveat
In theory, such a change may break some code. But empty strings are unlikely used as meaningful properties in practice. So we are not going to treat this as a major change.
The text was updated successfully, but these errors were encountered: