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:
Azure SDK Bot 2025-02-11 11:34:25 -08:00 committed by GitHub
parent be2241d86c
commit 4f2ca36252
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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()
}
}
}