Skip to content

Commit f36d192

Browse files
azure-sdkscbedd
andauthored
Sync eng/common directory with azure-sdk-tools for PR 9803 (#48232)
* update Get-ObjectKey to coalesce boolean-like values to their true boolean value * update Get-ObjectKey to call Get-ObjectKey on each item of an array or pscustom object - versus utilizing their values directly --------- Co-authored-by: Scott Beddall <scbedd@microsoft.com>
1 parent d8974da commit f36d192

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

eng/common/scripts/Helpers/Package-Helpers.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ function Get-ObjectKey {
178178

179179
if ($Object -is [hashtable] -or $Object -is [System.Collections.Specialized.OrderedDictionary]) {
180180
$sortedEntries = $Object.GetEnumerator() | Sort-Object Name
181-
$hashString = ($sortedEntries | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join ";"
181+
$hashString = ($sortedEntries | ForEach-Object { "$($_.Key)=$(Get-ObjectKey $_.Value)" }) -join ";"
182182
return $hashString.GetHashCode()
183183
}
184184

185185
elseif ($Object -is [PSCustomObject]) {
186186
$sortedProperties = $Object.PSObject.Properties | Sort-Object Name
187-
$propertyString = ($sortedProperties | ForEach-Object { "$($_.Name)=$($_.Value)" }) -join ";"
187+
$propertyString = ($sortedProperties | ForEach-Object { "$($_.Name)=$(Get-ObjectKey $_.Value)" }) -join ";"
188188
return $propertyString.GetHashCode()
189189
}
190190

@@ -194,7 +194,12 @@ function Get-ObjectKey {
194194
}
195195

196196
else {
197-
return $Object.GetHashCode()
197+
$parsedBool = $null
198+
if ([bool]::TryParse($Object, [ref]$parsedBool)) {
199+
return $parsedBool.GetHashCode()
200+
} else {
201+
return $Object.GetHashCode()
202+
}
198203
}
199204
}
200205

0 commit comments

Comments
 (0)