Windows-powershell / PowerShell-master /test /powershell /Language /Scripting /DeserializedMethods.Tests.ps1
Download PowerShell-master/test/powershell/Language/Scripting/DeserializedMethods.Tests.ps1 from MegaBites-AI/Windows-powershell: direct link, hf CLI and curl.
- Browser
- Download file 793 Bytes
-
https://huggingface.co/datasets/MegaBites-AI/Windows-powershell/resolve/main/PowerShell-master/test/powershell/Language/Scripting/DeserializedMethods.Tests.ps1
- Command line
-
hf download hf://datasets/MegaBites-AI/Windows-powershell/PowerShell-master/test/powershell/Language/Scripting/DeserializedMethods.Tests.ps1
-
curl -L -o DeserializedMethods.Tests.ps1 https://huggingface.co/datasets/MegaBites-AI/Windows-powershell/resolve/main/PowerShell-master/test/powershell/Language/Scripting/DeserializedMethods.Tests.ps1
793 Bytes
| # Copyright (c) Microsoft Corporation. | |
| # Licensed under the MIT License. | |
| Describe "DeserializedMethods" -Tags "CI" { | |
| 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) | |
| # 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) | |
| $d = [System.Management.Automation.PSSerializer]::Deserialize($s) | |
| $d | Get-Member -MemberType *Method* Add | Should -BeNullOrEmpty | |
| } | |
| } | |