Skip to content

Commit 356350b

Browse files
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.
1 parent 9ec863b commit 356350b

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ Pester can also be used to test code-coverage, like so:
422422

423423
```powershell
424424
$pesterConfig = New-PesterConfiguration
425-
$pesterConfig.CodeCoverage.Path = @("$root\GitHubLabels.ps1")
425+
$pesterConfig.CodeCoverage.Path = @("$root\GitHubLabels.ps1")
426426
$pesterConfig.CodeCoverage.Enabled = $true
427427
428428
Invoke-Pester -Configuration $pesterConfig
@@ -435,7 +435,7 @@ The code-coverage object can be captured and interacted with, like so:
435435

436436
```powershell
437437
$pesterConfig = New-PesterConfiguration
438-
$pesterConfig.CodeCoverage.Path = @("$root\GitHubLabels.ps1")
438+
$pesterConfig.CodeCoverage.Path = @("$root\GitHubLabels.ps1")
439439
$pesterConfig.CodeCoverage.Enabled = $true
440440
$pesterConfig.Run.PassThru = $true
441441
@@ -625,6 +625,7 @@ Thank you to all of our contributors, no matter how big or small the contributio
625625
- **[Neil White (@variableresistor)](https://github.com/variableresistor)**
626626
- **[Mark Curole(@tigerfansga)](https://github.com/tigerfansga)**
627627
- **[Jason Vercellone(@vercellone)](https://github.com/vercellone)**
628+
- **[Andy Jordan (@andyleejordan)](https://github.com/andyleejordan)**
628629

629630
----------
630631

Helpers.ps1

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,8 @@ function DeepCopy-Object
394394
[PSCustomObject] $InputObject
395395
)
396396

397-
$memoryStream = New-Object System.IO.MemoryStream
398-
$binaryFormatter = New-Object System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
399-
$binaryFormatter.Serialize($memoryStream, $InputObject)
400-
$memoryStream.Position = 0
401-
$DeepCopiedObject = $binaryFormatter.Deserialize($memoryStream)
402-
$memoryStream.Close()
403-
404-
return $DeepCopiedObject
397+
$serialData = [System.Management.Automation.PSSerializer]::Serialize($InputObject, 64)
398+
return [System.Management.Automation.PSSerializer]::Deserialize($serialData)
405399
}
406400

407401
function New-TemporaryDirectory

0 commit comments

Comments
 (0)