Files

21 lines
793 B
PowerShell
Raw Permalink Normal View History

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Describe "DeserializedMethods" -Tags "CI" {
2016-09-15 11:27:44 -07:00
It "Deserialized objects shouldn't ever have any methods (unless they are primitive known types)" {
$a = [collections.arraylist]::new()
$null = $a.Add(1)
$null = $a.Add(2)
$null = $a.Add(3)
2017-01-16 13:31:14 -08:00
2016-09-15 11:27:44 -07:00
# using linkedlist that implements IEnumerable,
# but doesn't implement IList or IList<T>
$x = [collections.generic.linkedlist[int]]::new()
$null = $x.Add(123)
$null = $x.Add(456)
$s = [System.Management.Automation.PSSerializer]::Serialize($x)
2017-01-16 13:31:14 -08:00
$d = [System.Management.Automation.PSSerializer]::Deserialize($s)
$d | Get-Member -MemberType *Method* Add | Should -BeNullOrEmpty
2016-09-15 11:27:44 -07:00
}
2020-01-13 18:36:47 +00:00
}