-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework passing array literal to native commands #5301
Conversation
@@ -43,4 +43,21 @@ Describe "Native Command Arguments" -tags "CI" { | |||
$lines[$i] | Should Be "Arg $i is <$($expected[$i])>" | |||
} | |||
} | |||
|
|||
It "Should handle PowerShell arrays with or without spaces correctly: <arguments>" -TestCases @( | |||
@{arguments = "a 1,2"; expected = "a", "1,2"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add something boring, like a,1,2
here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no difference between 2 and 3 elements - it's just spaces around the argument(s) that matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add 1,2 3
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really didn't need a 1,2
, 1,2
would have been sufficient, but I had a bug in the test with array vs. scalar and the first thought I had was to add a
to force array. I'm fixing by using @()
instead to force array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a comment
"array argument and ArrayLiteralAst differ in number of elements"); | ||
|
||
int currentElement = -1; | ||
string separator = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use String.Empty
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason to imo.
var beforeNext = next.Extent.StartOffset - 1; | ||
|
||
if (afterPrev == beforeNext) | ||
return ","; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please use one line formatting as above in line 357?
Below too in 376 and 379.
@@ -43,4 +43,21 @@ Describe "Native Command Arguments" -tags "CI" { | |||
$lines[$i] | Should Be "Arg $i is <$($expected[$i])>" | |||
} | |||
} | |||
|
|||
It "Should handle PowerShell arrays with or without spaces correctly: <arguments>" -TestCases @( | |||
@{arguments = "a 1,2"; expected = "a", "1,2"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add 1,2 3
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Now that the Ast is passed through to the NativeCommandParameterBinder, there is a cleaner fix to ensuring we pass the correct text to a command that uses PowerShell array syntax.