Skip to content

Commit 367fdc1

Browse files
authored
Merge pull request PowerShell#53 from JamesWTruher/jameswtruher/rc1
RC1 changes
2 parents 3e302f8 + f70e834 commit 367fdc1

File tree

9 files changed

+301
-744
lines changed

9 files changed

+301
-744
lines changed

PowerShellStandard.psm1

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@ function Start-Build {
66
$srcDir = Join-Path $srcBase $version
77
Push-Location $srcDir
88
dotnet restore
9-
dotnet build
9+
dotnet build --configuration Release
1010
}
1111
finally {
1212
Pop-Location
1313
}
1414
}
15+
16+
# push into dotnetTemplate and build
17+
try {
18+
$templateBase = Join-Path $srcBase dotnetTemplate
19+
Push-Location $templateBase
20+
dotnet restore
21+
dotnet build --configuration Release
22+
}
23+
finally {
24+
Pop-Location
25+
}
1526
}
1627

1728
function Start-Clean {
@@ -43,16 +54,21 @@ function Invoke-Test {
4354
try {
4455
$testBase = Join-Path $PsScriptRoot "test/${version}"
4556
Push-Location $testBase
46-
dotnet build
57+
dotnet build --configuration Release
4758
Invoke-Pester
4859
}
4960
finally {
5061
Pop-Location
5162
}
5263
}
5364

54-
Push-Location (Join-Path $PsScriptRoot "test/dotnetTemplate")
55-
Invoke-Pester
65+
try {
66+
Push-Location (Join-Path $PsScriptRoot "test/dotnetTemplate")
67+
Invoke-Pester
68+
}
69+
finally {
70+
Pop-Location
71+
}
5672
}
5773

5874
function Export-NuGetPackage
@@ -65,9 +81,9 @@ function Export-NuGetPackage
6581
try {
6682
$srcDir = Join-Path $srcBase $version
6783
Push-Location $srcDir
68-
$result = dotnet pack
84+
$result = dotnet pack --configuration Release
6985
if ( $? ) {
70-
Copy-Item -verbose:$true (Join-Path $srcDir "bin/Debug/PowerShellStandard.Library*.nupkg") $PsScriptRoot
86+
Copy-Item -verbose:$true (Join-Path $srcDir "bin/Release/PowerShellStandard.Library*.nupkg") $PsScriptRoot
7187
}
7288
else {
7389
Write-Error -Message "$result"
@@ -81,9 +97,9 @@ function Export-NuGetPackage
8197
try {
8298
$templateDir = Join-Path $PsScriptRoot src/dotnetTemplate
8399
Push-Location $templateDir
84-
$result = dotnet pack
100+
$result = dotnet pack --configuration Release
85101
if ( $? ) {
86-
Copy-Item -verbose:$true (Join-Path $templateDir "bin/Debug/*.nupkg") $PsScriptRoot
102+
Copy-Item -verbose:$true (Join-Path $templateDir "bin/Release/*.nupkg") $PsScriptRoot
87103
}
88104
else {
89105
Write-Error -Message "$result"

src/3/PowerShellStandard.Library.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</references>
1818
</metadata>
1919
<files>
20-
<file src="obj/Debug/netstandard2.0/System.Management.Automation.dll" target="lib/netstandard2.0" />
20+
<file src="obj/Release/netstandard2.0/System.Management.Automation.dll" target="lib/netstandard2.0" />
2121
</files>
2222
</package>
2323

src/5/PowerShellStandard.Library.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
33
<metadata>
44
<id>PowerShellStandard.Library</id>
5-
<version>5.1.0-preview-06</version>
5+
<version>5.1.0-RC1</version>
66
<authors>Microsoft</authors>
77
<owners>Microsoft,PowerShellTeam</owners>
88
<projectUrl>https://github.com/PowerShell/PowerShellStandard</projectUrl>
99
<iconUrl>https://github.com/PowerShell/PowerShell/blob/master/assets/Powershell_64.png</iconUrl>
1010
<licenseUrl>https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txt</licenseUrl>
1111
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1212
<description>Contains the reference assemblies for PowerShell Standard 5</description>
13-
<copyright>(c) Microsoft Corporation. All rights reserved.</copyright>
13+
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
1414
<tags>PowerShell, reference, netstandard2, netstandard2.0</tags>
1515
<references>
1616
<reference file="System.Management.Automation.dll" />
1717
</references>
1818
</metadata>
1919
<files>
20-
<file src="obj/Debug/netstandard2.0/System.Management.Automation.dll" target="lib/netstandard2.0" />
20+
<file src="obj/Release/netstandard2.0/System.Management.Automation.dll" target="lib/netstandard2.0" />
2121
</files>
2222
</package>
2323

src/5/System.Management.Automation-lib.cs

Lines changed: 29 additions & 708 deletions
Large diffs are not rendered by default.

src/dotnetTemplate/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template/Microsoft.PowerShell.Standard.Module.Template.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0-preview-06">
9+
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0-RC1">
1010
<PrivateAssets>All</PrivateAssets>
1111
</PackageReference>
1212

test/3/PSS3.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Describe "PowerShell Standard 3" {
22
BeforeAll {
3-
$cmdletAssembly = "bin/Debug/netstandard2.0/Demo.Cmdlet.dll"
3+
$cmdletAssembly = "bin/Release/netstandard2.0/Demo.Cmdlet.dll"
44
$assemblyPath = Join-Path "$PSScriptRoot" $cmdletAssembly
55
$PSBin = (Get-Process -id $PID).MainModule.FileName
66
}
77
It "Can build a reference assembly" {
88
dotnet restore
9-
dotnet build
9+
dotnet build --configuration Release
1010
$assemblyPath | Should Exist
1111
}
1212
It "Can execute the compiled cmdlet" {

test/5/PSS5.Tests.ps1

Lines changed: 235 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,242 @@
1-
Describe "PowerShell Standard 5" {
1+
Describe 'PowerShell Standard 5' {
2+
23
BeforeAll {
3-
$cmdletAssembly = "bin/Debug/netstandard2.0/Demo.Cmdlet.dll"
4-
$assemblyPath = Join-Path "$PSScriptRoot" $cmdletAssembly
5-
$PSBin = (Get-Process -id $PID).MainModule.FileName
4+
$repoRoot = git rev-parse --show-toplevel
5+
$libraryPath = "${repoRoot}/src/5/bin/Release/netstandard2.0/System.Management.Automation.dll"
6+
$assemblyExists = test-path $libraryPath
7+
if ( $assemblyExists ) {
8+
$standardAssembly = [System.Reflection.Assembly]::LoadFile($libraryPath)
9+
}
610
}
7-
It "Can build a reference assembly" {
8-
try {
9-
Push-Location $PSScriptRoot
10-
dotnet restore
11-
dotnet build
12-
$assemblyPath | Should Exist
11+
12+
Context 'Creating a cmdlet' {
13+
BeforeAll {
14+
$cmdletAssembly = 'bin/Release/netstandard2.0/Demo.Cmdlet.dll'
15+
$assemblyPath = Join-Path "$PSScriptRoot" $cmdletAssembly
16+
$PSBin = (Get-Process -id $PID).MainModule.FileName
17+
}
18+
It 'Can build a reference assembly' {
19+
try {
20+
Push-Location $PSScriptRoot
21+
dotnet restore
22+
dotnet build --configuration Release
23+
$assemblyPath | Should -Exist
24+
}
25+
finally {
26+
Pop-Location
27+
}
1328
}
14-
finally {
15-
Pop-Location
29+
It 'Can execute the compiled cmdlet' {
30+
$result = & $PSBin -c "import-module $assemblyPath; Get-Thing"
31+
$result | Should -Be 'success!'
1632
}
1733
}
18-
It "Can execute the compiled cmdlet" {
19-
$result = & $PSBin -c "import-module $assemblyPath; Get-Thing"
20-
$result | Should Be "success!"
34+
35+
Context 'Reflection tests' {
36+
37+
$testCases = @{
38+
Name = "Issue 52: ValidateArgumentsAttribute.Validate method is not abstract"
39+
ScriptBlock = {
40+
$t = $standardAssembly.GetType('System.Management.Automation.ValidateArgumentsAttribute')
41+
$m = $t.GetMember('Validate','Public,NonPublic,Instance,Static,DeclaredOnly')
42+
$m.IsAbstract |Should -Be $true
43+
}
44+
},
45+
@{
46+
Name = "Issue 50: PSEventUnsubscribedEventHander argument type should be PSEventUnsubscribedEventArgs"
47+
ScriptBlock = {
48+
$t = $standardAssembly.GetType('System.Management.Automation.PSEventUnsubscribedEventHandler')
49+
$m = $t.GetMethod('Invoke')
50+
$parameters = $m.GetParameters()
51+
$parameters[1].ParameterType.FullName | Should -Be 'System.Management.Automation.PSEventUnsubscribedEventArgs'
52+
}
53+
},
54+
@{
55+
Name = "Issue 44: FunctionMemberAst.Parameters should be accessible"
56+
ScriptBlock = {
57+
$t = $standardAssembly.GetType('System.Management.Automation.Language.FunctionMemberAst')
58+
$p = $t.GetProperty('Parameters')
59+
$p.GetMethod.IsPublic | Should -Be $true
60+
}
61+
},
62+
@{
63+
Name = "Issue 42: Runspace.Default should not contain public CreateNestedPipeline"
64+
ScriptBlock = {
65+
$t = $standardAssembly.GetType('System.Management.Automation.Runspaces.Runspace')
66+
$t.GetMembers('Public,NonPublic,Instance,Static')|?{$_.Name -match 'CreatedNestedPipeline'}|Should -BeNullOrEmpty
67+
}
68+
},
69+
@{
70+
Name = "Issue 36: PSMemberInfo.Copy is marked 'virtual' but should be 'abstract'"
71+
ScriptBlock = {
72+
$t = $standardAssembly.GetType('System.Management.Automation.PSMemberInfo')
73+
$m = $t.GetMethod('Copy')
74+
$m.IsAbstract | Should -Be $true
75+
}
76+
},
77+
@{
78+
Name = "Issue 26: Several properties missing from CmdletProvider (also issue 14)"
79+
ScriptBlock = {
80+
$t = $standardAssembly.GetType('System.Management.Automation.Provider.CmdletProvider')
81+
$t.GetProperty('CurrentPSTransaction') | Should -Not -BeNullOrEmpty
82+
$t.GetProperty('DynamicParameters',[Reflection.BindingFlags]'NonPublic,Instance') | Should -Not -BeNullOrEmpty
83+
$t.GetProperty('PSDriveInfo',[Reflection.BindingFlags]'NonPublic,Instance') | Should -Not -BeNullOrEmpty
84+
$t.GetProperty('ProviderInfo',[Reflection.BindingFlags]'NonPublic,Instance') | Should -Not -BeNullOrEmpty
85+
}
86+
},
87+
@{
88+
Name = "Issue 19: SetJobState missing from Job class"
89+
ScriptBlock = {
90+
$t = $standardAssembly.GetType('System.Management.Automation.Job')
91+
$t.GetMethod('SetJobState',[System.Reflection.BindingFlags]'NonPublic,Instance') | Should -Not -BeNullOrEmpty
92+
}
93+
},
94+
@{
95+
Name = "Issue 18: Debugger does not contain protected parameterless constructor"
96+
ScriptBlock = {
97+
$t = $standardAssembly.GetType('System.Management.Automation.Debugger')
98+
# no public constructors
99+
$t.GetConstructors().Count | Should -Be 0
100+
# one protected, parameterless constructor
101+
$constructor = $t.GetConstructors('NonPublic,Instance')
102+
@($constructor).Count | Should -Be 1
103+
$constructor.IsFamily | Should -Be $true
104+
$constructor.GetParameters().Count | Should -Be 0
105+
}
106+
},
107+
@{
108+
Name = "Issue 17: ScriptExtent does not inherit IScriptExtent"
109+
ScriptBlock = {
110+
$t = $standardAssembly.GetType('System.Management.Automation.Language.ScriptExtent')
111+
$t.GetInterface('System.Management.Automation.Language.IScriptExtent')|Should -Not -BeNullOrEmpty
112+
}
113+
},
114+
@{
115+
Name = "Issue 16: ICustomAstVistor2 does not inherit ICustomAstVistor"
116+
ScriptBlock = {
117+
$t = $standardAssembly.GetType('System.Management.Automation.Language.ICustomAstVisitor2')
118+
$t.GetInterface('System.Management.Automation.Language.ICustomAstVisitor')|Should -Not -BeNullOrEmpty
119+
}
120+
},
121+
@{
122+
Name = "Issue 11: Missing cmdletization types"
123+
ScriptBlock = {
124+
$typeList = 'Microsoft.PowerShell.Cmdletization.BehaviorOnNoMatch',
125+
'Microsoft.PowerShell.Cmdletization.CmdletAdapter`1',
126+
'Microsoft.PowerShell.Cmdletization.MethodInvocationInfo', 'Microsoft.PowerShell.Cmdletization.MethodParameter',
127+
'Microsoft.PowerShell.Cmdletization.MethodParameterBindings',
128+
'Microsoft.PowerShell.Cmdletization.QueryBuilder',
129+
'Microsoft.PowerShell.Cmdletization.Xml.ConfirmImpact', 'Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType'
130+
foreach ( $t in $typeList ) {
131+
$standardAssembly.GetType($t) | Should -Not -BeNullOrEmpty
132+
}
133+
}
134+
},
135+
@{
136+
Name = "Issue 8: DefaultRunspace should be a static property"
137+
ScriptBlock = {
138+
$t = $standardAssembly.GetType('System.Management.Automation.Runspaces.Runspace')
139+
$p = $t.GetProperty('DefaultRunspace',[System.Reflection.BindingFlags]'Public,Static')
140+
$p | Should -Not -BeNullOrEmpty
141+
}
142+
},
143+
@{
144+
Name = "Issue 7: params keyword is left out for array type parameters"
145+
ScriptBlock = {
146+
$t = $standardAssembly.GetType('System.Management.Automation.OutputTypeAttribute')
147+
foreach ($c in $t.GetConstructors()) {
148+
$c.GetParameters()[-1].CustomAttributes.AttributeType.FullName | Should -Be System.ParamArrayAttribute
149+
}
150+
}
151+
},
152+
@{
153+
Name = "Issue 6: PSObject.Properties is using int instead of string"
154+
ScriptBlock = {
155+
$t = $standardAssembly.GetType('System.Management.Automation.PSObject')
156+
$p = $t.GetProperty('Properties')
157+
$p.PropertyType.GetMember('Item').GetIndexParameters().ParameterType.FullName | Should -Be 'System.String'
158+
}
159+
},
160+
@{
161+
Name = "Issue 4: CreatePipeline should not be available"
162+
ScriptBlock = {
163+
$t = $standardAssembly.GetType('System.Management.Automation.Runspaces.Runspace')
164+
$t.GetMembers('Public,NonPublic,Instance,Static')|?{$_.Name -match 'CreatePipeline'} | Should -BeNullOrEmpty
165+
}
166+
}
167+
168+
It '<Name>' -testcases $testCases -skip:(! $assemblyExists) {
169+
param ( [string]$name, [scriptblock]$ScriptBlock )
170+
& ${ScriptBlock}
171+
}
172+
}
173+
174+
Context 'The type list is expected' {
175+
BeforeAll {
176+
$smaT = [psobject].assembly.GetTypes()|?{$_.IsPublic}|Sort-Object FullName
177+
$asmT = $standardAssembly.GetTypes()|?{$_.IsPublic}|Sort-Object FullName
178+
# These are the types which we expect to not be in the standard library
179+
$expectedMissingTypes = @{ Name = 'Microsoft.PowerShell.ProcessCodeMethods' },
180+
@{ Name = 'Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformationAttribute' },
181+
@{ Name = 'Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscRemoteOperationsClass' },
182+
@{ Name = 'Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache' },
183+
@{ Name = 'Microsoft.PowerShell.Commands.GetExperimentalFeatureCommand' },
184+
@{ Name = 'Microsoft.PowerShell.Commands.PSPropertyExpressionResult' },
185+
@{ Name = 'Microsoft.PowerShell.Commands.PSPropertyExpression' },
186+
@{ Name = 'Microsoft.PowerShell.Commands.UpdateHelpScope' },
187+
@{ Name = 'Microsoft.PowerShell.CoreClr.Stubs.AuthenticationLevel' },
188+
@{ Name = 'Microsoft.PowerShell.CoreClr.Stubs.ImpersonationLevel' },
189+
@{ Name = 'System.Management.Automation.PowerShellAssemblyLoadContextInitializer' },
190+
@{ Name = 'System.Management.Automation.Platform' },
191+
@{ Name = 'System.Management.Automation.ValidateRangeKind' },
192+
@{ Name = 'System.Management.Automation.CachedValidValuesGeneratorBase' },
193+
@{ Name = 'System.Management.Automation.IValidateSetValuesGenerator' },
194+
@{ Name = 'System.Management.Automation.ArgumentCompletionsAttribute' },
195+
@{ Name = 'System.Management.Automation.GetSymmetricEncryptionKey' },
196+
@{ Name = 'System.Management.Automation.StartRunspaceDebugProcessingEventArgs' },
197+
@{ Name = 'System.Management.Automation.ProcessRunspaceDebugEndEventArgs' },
198+
@{ Name = 'System.Management.Automation.ExperimentalFeature' },
199+
@{ Name = 'System.Management.Automation.ExperimentAction' },
200+
@{ Name = 'System.Management.Automation.ExperimentalAttribute' },
201+
@{ Name = 'System.Management.Automation.PSSnapInSpecification' },
202+
@{ Name = 'System.Management.Automation.PSParseError' },
203+
@{ Name = 'System.Management.Automation.PSParser' },
204+
@{ Name = 'System.Management.Automation.PSToken' },
205+
@{ Name = 'System.Management.Automation.PSTokenType' },
206+
@{ Name = 'System.Management.Automation.TypeInferenceRuntimePermissions' },
207+
@{ Name = 'System.Management.Automation.PSVersionHashTable' },
208+
@{ Name = 'System.Management.Automation.SemanticVersion' },
209+
@{ Name = 'System.Management.Automation.LocationChangedEventArgs' },
210+
@{ Name = 'System.Management.Automation.WorkflowInfo' },
211+
@{ Name = 'System.Management.Automation.PSSnapInInfo' },
212+
@{ Name = 'System.Management.Automation.VerbInfo' },
213+
@{ Name = 'System.Management.Automation.Remoting.WSMan.WSManServerChannelEvents' },
214+
@{ Name = 'System.Management.Automation.Remoting.WSMan.ActiveSessionsChangedEventArgs' },
215+
@{ Name = 'System.Management.Automation.Runspaces.PipelineStateInfo' },
216+
@{ Name = 'System.Management.Automation.Runspaces.PipelineStateEventArgs' },
217+
@{ Name = 'System.Management.Automation.Runspaces.Pipeline' },
218+
@{ Name = 'System.Management.Automation.Runspaces.PowerShellProcessInstance' },
219+
@{ Name = 'System.Management.Automation.Runspaces.SSHConnectionInfo' },
220+
@{ Name = 'System.Management.Automation.Runspaces.VMConnectionInfo' },
221+
@{ Name = 'System.Management.Automation.Runspaces.PSSnapInException' },
222+
@{ Name = 'System.Management.Automation.Runspaces.PipelineReader`1' },
223+
@{ Name = 'System.Management.Automation.Runspaces.PipelineWriter' },
224+
@{ Name = 'System.Management.Automation.Tracing.EtwActivity' },
225+
@{ Name = 'System.Management.Automation.Tracing.PowerShellTraceTask' },
226+
@{ Name = 'System.Management.Automation.Tracing.PowerShellTraceKeywords' },
227+
@{ Name = 'System.Management.Automation.Tracing.Tracer' },
228+
@{ Name = 'System.Management.Automation.Tracing.PowerShellTraceSource' },
229+
@{ Name = 'System.Management.Automation.Tracing.PowerShellTraceSourceFactory' },
230+
@{ Name = 'System.Management.Automation.Internal.TransactionParameters' }
231+
}
232+
233+
It "There should be no types in standard which are not in the product" -skip:(! $assemblyExists) {
234+
Compare-Object -reference $smaT -difference $asmT | ?{$_.SideIndicator -eq '=>' } | Should -BeNullOrEmpty
235+
}
236+
237+
It "<Name> should not be in the standard library" -skip:(! $assemblyExists) -testcase $expectedMissingTypes {
238+
param ( $Name )
239+
$Name | Should -BeIn @($expectedMissingTypes.Values)
240+
}
21241
}
22242
}

0 commit comments

Comments
 (0)