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
{{ message }}
Repository navigation
Enable tab completion for variables that are of enum type #10631
Ideally, this should also work for flag (bit-field) enumerations, so that something like the following would work:
# Sample flags enumeration.
[Flags()] enum Foo { first =0x1; second =0x2; third =0x4 }
# Tab-complete flag values inside strings too (with or without a closing quote present).
[Foo] 'first, th'<tab># -> 'first, third', tantamount to [Foo]::first -bor [Foo]::third
I'm thinking that even $ErrorActionPreference = <tab> (no opening quote) should complete to a string (e.g, $ErrorActionPreference = 'Stop'), for two reasons:
Using types and static properties is an advanced technique, and strings are more concise and provide better symmetry with use in arguments (e.g., -ErrorAction Stop), where use of the static property expression would be impractical (e.g., -ErrorAction ([System.Management.Automation.ActionPreference]::Stop))
With flag enumerations, a string value is easier to modify later (again with tab-completion support), especially when new flags are added (e.g., 'Compiled' -> 'Compiled, IgnoreCase' vs. [System.Text.RegularExpressions.RegexOptions]::Compiled -> [System.Text.RegularExpressions.RegexOptions]::Compiled -bor [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
Reacted by Patrick Meinecke and Rain Sallow (/u/ta11ow)
Activity
mklement0 commentedon Sep 26, 2019
That would be an excellent improvement.
Ideally, this should also work for flag (bit-field) enumerations, so that something like the following would work:
SeeminglyScience commentedon Sep 27, 2019
Should it be that or should it be:
If the former, would it complete to a string or to a static member expression?
Also would be fantastic if this worked on convert expressions (like in Michael Klement (@mklement0)'s example)
mklement0 commentedon Sep 27, 2019
Good question, Patrick Meinecke (@SeeminglyScience).
I'm thinking that even
$ErrorActionPreference = <tab>(no opening quote) should complete to a string (e.g,$ErrorActionPreference = 'Stop'), for two reasons:Using types and static properties is an advanced technique, and strings are more concise and provide better symmetry with use in arguments (e.g.,
-ErrorAction Stop), where use of the static property expression would be impractical (e.g.,-ErrorAction ([System.Management.Automation.ActionPreference]::Stop))With flag enumerations, a string value is easier to modify later (again with tab-completion support), especially when new flags are added (e.g.,
'Compiled'->'Compiled, IgnoreCase'vs.[System.Text.RegularExpressions.RegexOptions]::Compiled->[System.Text.RegularExpressions.RegexOptions]::Compiled -bor [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)SteveL-MSFT commentedon Sep 28, 2019
I think string is definitely more user friendly.
SteveL-MSFT commentedon Sep 29, 2019
Michael Klement (@mklement0) please open a new issue for flags
mklement0 commentedon Sep 29, 2019
Steve Lee (@SteveL-MSFT): Please see #10647