2020-03-24 19:08:37 +01:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
2018-02-13 18:23:53 +01:00
|
|
|
# Licensed under the MIT License.
|
|
|
|
Describe "DeserializedMethods" -Tags "CI" {
|
2016-09-15 20:27:44 +02: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 22:31:14 +01:00
|
|
|
|
2016-09-15 20:27:44 +02: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 22:31:14 +01:00
|
|
|
$d = [System.Management.Automation.PSSerializer]::Deserialize($s)
|
|
|
|
|
2018-03-21 18:47:08 +01:00
|
|
|
$d | Get-Member -MemberType *Method* Add | Should -BeNullOrEmpty
|
2016-09-15 20:27:44 +02:00
|
|
|
}
|
2020-01-13 19:36:47 +01:00
|
|
|
}
|