Replace `BinaryFormatter` with `PSSerializer` (#415)

Replace `BinaryFormatter` with `PSSerializer`

Since the former has been removed from PowerShell 7.4 (because it was removed from .NET 7) and the latter can accomplish the same thing.

The default depth is 1, so we need to specify. Best I could find was that the prior implementation defaulted to a depth of 64, so we're going with that.
This commit is contained in:
Andy Jordan 2023-11-20 16:36:18 -08:00 коммит произвёл GitHub
Родитель 9ec863b142
Коммит 356350b22f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 5 добавлений и 10 удалений

Просмотреть файл

@ -422,7 +422,7 @@ Pester can also be used to test code-coverage, like so:
```powershell
$pesterConfig = New-PesterConfiguration
$pesterConfig.CodeCoverage.Path = @("$root\GitHubLabels.ps1")
$pesterConfig.CodeCoverage.Path = @("$root\GitHubLabels.ps1")
$pesterConfig.CodeCoverage.Enabled = $true
Invoke-Pester -Configuration $pesterConfig
@ -435,7 +435,7 @@ The code-coverage object can be captured and interacted with, like so:
```powershell
$pesterConfig = New-PesterConfiguration
$pesterConfig.CodeCoverage.Path = @("$root\GitHubLabels.ps1")
$pesterConfig.CodeCoverage.Path = @("$root\GitHubLabels.ps1")
$pesterConfig.CodeCoverage.Enabled = $true
$pesterConfig.Run.PassThru = $true
@ -625,6 +625,7 @@ Thank you to all of our contributors, no matter how big or small the contributio
- **[Neil White (@variableresistor)](https://github.com/variableresistor)**
- **[Mark Curole(@tigerfansga)](https://github.com/tigerfansga)**
- **[Jason Vercellone(@vercellone)](https://github.com/vercellone)**
- **[Andy Jordan (@andyleejordan)](https://github.com/andyleejordan)**
----------

Просмотреть файл

@ -394,14 +394,8 @@ function DeepCopy-Object
[PSCustomObject] $InputObject
)
$memoryStream = New-Object System.IO.MemoryStream
$binaryFormatter = New-Object System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
$binaryFormatter.Serialize($memoryStream, $InputObject)
$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 New-TemporaryDirectory