File tree Expand file tree Collapse file tree 1 file changed +24
-5
lines changed
eng/common/scripts/Helpers Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -210,14 +210,33 @@ function Group-ByObjectKey {
210210 $groupedDictionary = @ {}
211211
212212 foreach ($item in $Items ) {
213- $key = Get-ObjectKey $item ." $GroupByProperty "
213+ # if the item is an array, we need to group by each element in the array
214+ # however if it's an empty array we want to treat it as a single item
215+ if ($item ." $GroupByProperty " -and $item ." $GroupByProperty " -is [array ]) {
216+ foreach ($GroupByPropertyValue in $item ." $GroupByProperty " ) {
217+ $key = Get-ObjectKey $GroupByPropertyValue
214218
215- if (-not $groupedDictionary.ContainsKey ($key )) {
216- $groupedDictionary [$key ] = @ ()
219+ if (-not $groupedDictionary.ContainsKey ($key )) {
220+ $groupedDictionary [$key ] = @ ()
221+ }
222+
223+ $groupedDictionary [$key ] += $item
224+ }
217225 }
226+ else {
227+ if ($item ." $GroupByProperty " ) {
228+ $key = Get-ObjectKey $item ." $GroupByProperty "
229+ }
230+ else {
231+ $key = " unset"
232+ }
233+
234+ if (-not $groupedDictionary.ContainsKey ($key )) {
235+ $groupedDictionary [$key ] = @ ()
236+ }
218237
219- # Add the current item to the array for this key
220- $groupedDictionary [ $key ] += $item
238+ $groupedDictionary [ $key ] += $ item
239+ }
221240 }
222241
223242 return $groupedDictionary
You can’t perform that action at this time.
0 commit comments