Skip to content

Commit

Permalink
Replace BinaryFormatter with PSSerializer (#241)
Browse files Browse the repository at this point in the history
BinaryFormatter has been removed from PowerShell 7.4 (since it was removed from .NET 7), so replacing with PSSerializer which can accomplish the same thing.
  • Loading branch information
HowardWolosky authored Feb 1, 2024
1 parent e419452 commit 2a220bd
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions StoreBroker/Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,8 @@ function DeepCopy-Object
[PSCustomObject] $Object
)

$memoryStream = New-Object System.IO.MemoryStream
$binaryFormatter = New-Object System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
$binaryFormatter.Serialize($memoryStream, $Object)
$memoryStream.Position = 0
$DeepCopiedObject = $binaryFormatter.Deserialize($memoryStream)
$memoryStream.Close()

return $DeepCopiedObject
$serialData = [System.Management.Automation.PSSerializer]::Serialize($InputObject, 64)
return [System.Management.Automation.PSSerializer]::Deserialize($serialData)
}

function Get-SHA512Hash
Expand Down

0 comments on commit 2a220bd

Please sign in to comment.