Sync eng/common directory with azure-sdk-tools for PR 9803 (#6408)
* 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>
This commit is contained in:
parent
be2241d86c
commit
4f2ca36252
@ -178,13 +178,13 @@ function Get-ObjectKey {
|
||||
|
||||
if ($Object -is [hashtable] -or $Object -is [System.Collections.Specialized.OrderedDictionary]) {
|
||||
$sortedEntries = $Object.GetEnumerator() | Sort-Object Name
|
||||
$hashString = ($sortedEntries | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join ";"
|
||||
$hashString = ($sortedEntries | ForEach-Object { "$($_.Key)=$(Get-ObjectKey $_.Value)" }) -join ";"
|
||||
return $hashString.GetHashCode()
|
||||
}
|
||||
|
||||
elseif ($Object -is [PSCustomObject]) {
|
||||
$sortedProperties = $Object.PSObject.Properties | Sort-Object Name
|
||||
$propertyString = ($sortedProperties | ForEach-Object { "$($_.Name)=$($_.Value)" }) -join ";"
|
||||
$propertyString = ($sortedProperties | ForEach-Object { "$($_.Name)=$(Get-ObjectKey $_.Value)" }) -join ";"
|
||||
return $propertyString.GetHashCode()
|
||||
}
|
||||
|
||||
@ -194,7 +194,12 @@ function Get-ObjectKey {
|
||||
}
|
||||
|
||||
else {
|
||||
return $Object.GetHashCode()
|
||||
$parsedBool = $null
|
||||
if ([bool]::TryParse($Object, [ref]$parsedBool)) {
|
||||
return $parsedBool.GetHashCode()
|
||||
} else {
|
||||
return $Object.GetHashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user