Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 9803 (#24091)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
azure-sdk and scbedd authored Feb 11, 2025
1 parent 2f4e20b commit cdb427a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions eng/common/scripts/Helpers/Package-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

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

Expand Down

0 comments on commit cdb427a

Please sign in to comment.