Skip to content

Commit 209564a

Browse files
Release 1.1.0 (#6)
* Add Find-Namespace cmdlet - Add Find-Namespace cmdlet for discovering namespaces and making it easier to filter by namespace. - Add argument completion for namespaces and namespace names - Add Not parameter to Find-* cmdlets to negate matches. - Fix an issue where the Find-* cmdlets would return all matches in the AppDomain when passed null pipeline input. * Add namespace input support Find-* - Add support for NamespaceInfo objects as pipeline input for the other Find-* cmdlets - Fix Not parameter support Find-* cmdlets - Fix ExpectingInput support for Find-* cmdlets - Add argument completion for the Find-Type parameter "Namespace" * Add assembly name argument completion * Update help to reflect parameter changes * Refactor build process - Update development dependencies - Update microsoft/powershell docker container for CircleCI - Add a standalone build.ps1 that should be invokable with no installed development dependencies - Add release folder to AppVeyor artifacts * Refactor tests - Replace custom assertion functions with custom assertion operators - Add tests for new argument completers, Find-Namespace, and new parameters * Fix AppVeyor error * Update release notes
1 parent d136325 commit 209564a

31 files changed

+1344
-131
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ jobs:
33
build:
44
working_directory: ~/classexplorer
55
docker:
6-
- image: microsoft/powershell@sha256:6d36c498c1fdbb3ef42acabea1d06b12870e390fd3053993974ebaa6ba507849
6+
- image: microsoft/powershell@sha256:c0bd0f7ad40bcc76130cb5e772515546e3d200f8a416a273b2605a942d9775f5
77
steps:
88
- checkout
99
- run:
1010
name: Run build script
11-
command: 'powershell -File ./tools/InvokeCircleCI.ps1'
11+
command: 'pwsh -File ./tools/InvokeCircleCI.ps1'
1212
- store_artifacts:
1313
path: ./testresults/pester.xml
1414
prefix: tests

ClassExplorer.build.ps1

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
#requires -Module InvokeBuild, Pester, PlatyPS -Version 5.1
1+
#requires -Version 5.1
22

33
[CmdletBinding()]
44
param(
55
[ValidateSet('Debug', 'Release')]
6-
[string]
7-
$Configuration = 'Debug',
6+
[string] $Configuration = 'Debug',
87

9-
[switch]
10-
$GenerateCodeCoverage
8+
[switch] $GenerateCodeCoverage,
9+
10+
[switch] $Force
1111
)
1212

1313
$moduleName = 'ClassExplorer'
14-
$manifest = Test-ModuleManifest -Path $PSScriptRoot\module\$moduleName.psd1 `
15-
-ErrorAction Ignore `
16-
-WarningAction Ignore
14+
$testModuleManifestSplat = @{
15+
ErrorAction = 'Ignore'
16+
WarningAction = 'Ignore'
17+
Path = "$PSScriptRoot\module\$moduleName.psd1"
18+
}
19+
20+
$manifest = Test-ModuleManifest @testModuleManifestSplat
1721

1822
$script:Settings = @{
1923
Name = $moduleName
@@ -39,13 +43,33 @@ $script:Discovery = @{
3943
}
4044

4145
$tools = "$PSScriptRoot\tools"
46+
$script:GetDotNet = Get-Command $tools\GetDotNet.ps1
4247
$script:CreateFormatDefinitions = Get-Command $tools\CreateFormatDefinitions.ps1
43-
$script:dotnet = & $tools\GetDotNet.ps1 -Unix:$Discovery.IsUnix
48+
$script:AssertModule = Get-Command $tools\AssertRequiredModule.ps1
49+
$script:GetOpenCover = Get-Command $tools\GetOpenCover.ps1
4450

45-
if ($GenerateCodeCoverage.IsPresent) {
46-
$script:openCover = & $tools\GetOpenCover.ps1
51+
task AssertDotNet {
52+
$script:dotnet = & $GetDotNet -Unix:$Discovery.IsUnix
4753
}
4854

55+
task AssertOpenCover -If { $GenerateCodeCoverage.IsPresent } {
56+
if ($Discovery.IsUnix) {
57+
Write-Warning 'Generating code coverage from .NET core is currently unsupported, disabling code coverage generation.'
58+
$script:GenerateCodeCoverage = $false
59+
return
60+
}
61+
62+
$script:openCover = & $GetOpenCover
63+
}
64+
65+
task AssertRequiredModules {
66+
& $AssertModule Pester 4.1.1 -Force:$Force.IsPresent
67+
& $AssertModule InvokeBuild 5.0.0 -Force:$Force.IsPresent
68+
& $AssertModule platyPS 0.9.0 -Force:$Force.IsPresent
69+
}
70+
71+
# TODO: Look into replacing this junk with PSDepend
72+
task AssertDevDependencies -Jobs AssertDotNet, AssertOpenCover, AssertRequiredModules
4973

5074
task Clean {
5175
if ($PSScriptRoot -and (Test-Path $PSScriptRoot\Release)) {
@@ -66,9 +90,6 @@ task BuildDocs -If { $Discovery.HasDocs } {
6690
$releaseDocs = '{0}\{1}' -f $Folders.Release, $PSCulture
6791

6892
$null = New-Item $releaseDocs -ItemType Directory -Force -ErrorAction SilentlyContinue
69-
if ($Discovery.IsUnix) {
70-
Write-Host -ForegroundColor Green 'The mkdir errors below are fine, they''re due to a alias in platyPS'
71-
}
7293
$null = New-ExternalHelp -Path $sourceDocs -OutputPath $releaseDocs
7394
}
7495

@@ -123,12 +144,14 @@ task DoTest -If { $Discovery.HasTests -and $Settings.ShouldTest } {
123144
[System.Text.Encoding]::Unicode.GetBytes(
124145
$scriptString))
125146

126-
$powershell = (Get-Command powershell).Source
147+
$powershellCommand = 'powershell'
148+
if ($Discovery.IsUnix) {
149+
$powershellCommand = 'pwsh'
150+
}
151+
152+
$powershell = (Get-Command $powershellCommand).Source
127153

128154
if ($GenerateCodeCoverage.IsPresent) {
129-
if ($Discovery.IsUnix) {
130-
throw 'Generating code coverage from .NET core is currently unsupported.'
131-
}
132155
# OpenCover needs full pdb's. I'm very open to suggestions for streamlining this...
133156
& $dotnet clean
134157
& $dotnet build --configuration $Configuration --framework net452 /p:DebugType=Full
@@ -185,7 +208,7 @@ task DoPublish {
185208
Publish-Module -Name $Folders.Release -NuGetApiKey $apiKey -Confirm
186209
}
187210

188-
task Build -Jobs Clean, BuildDll, CopyToRelease, BuildDocs, BuildFormat
211+
task Build -Jobs AssertDevDependencies, Clean, BuildDll, CopyToRelease, BuildDocs, BuildFormat
189212

190213
task Test -Jobs Build, DoTest
191214

appveyor.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ install:
77
- ps: >-
88
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
99
10-
Install-Module Pester -RequiredVersion 4.0.6 -Scope CurrentUser -Force -SkipPublisherCheck
10+
Install-Module Pester -RequiredVersion 4.1.1 -Scope CurrentUser -Force -SkipPublisherCheck
1111
12-
Install-Module InvokeBuild -RequiredVersion 3.2.1 -Scope CurrentUser -Force
12+
Install-Module InvokeBuild -RequiredVersion 5.0.0 -Scope CurrentUser -Force
1313
14-
Install-Module platyPS -RequiredVersion 0.8.1 -Scope CurrentUser -Force
14+
Install-Module platyPS -RequiredVersion 0.9.0 -Scope CurrentUser -Force
1515
1616
choco install codecov --no-progress
1717
build_script:
1818
- ps: >-
19-
Invoke-Build -Task Prerelease -Configuration Release -GenerateCodeCoverage
19+
. "$PWD\build.ps1" -Force
2020
2121
$resultsFile = "$PWD\testresults\pester.xml"
2222
@@ -30,3 +30,12 @@ build_script:
3030
$Error | Format-List * -Force
3131
exit 1;
3232
}
33+
on_finish:
34+
- ps: >-
35+
Add-Type -AssemblyName System.IO.Compression.FileSystem
36+
37+
$zipPath = "$pwd\ClassExplorer.zip"
38+
39+
[System.IO.Compression.ZipFile]::CreateFromDirectory("$pwd\Release", $zipPath)
40+
41+
Push-AppveyorArtifact $zipPath

build.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[CmdletBinding()]
2+
param(
3+
[switch] $Force
4+
)
5+
end {
6+
& "$PSScriptRoot\tools\AssertRequiredModule.ps1" InvokeBuild 5.0.0 -Force:$Force.IsPresent
7+
$invokeBuildSplat = @{
8+
Task = 'PreRelease'
9+
File = "$PSScriptRoot/ClassExplorer.build.ps1"
10+
GenerateCodeCoverage = $true
11+
Force = $Force.IsPresent
12+
Configuration = 'Release'
13+
}
14+
15+
Invoke-Build @invokeBuildSplat
16+
}

docs/en-US/ClassExplorer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ ClassExplorer is a PowerShell module that enables quickly searching the AppDomai
1818

1919
The Find-Member cmdlet searches the AppDomain for members that fit specified criteria. You can search the entire AppDomain, search in specific types, or filter an existing list of members.
2020

21+
### [Find-Namespace](Find-Namespace.md)
22+
23+
The Find-Namespace cmdlet searches the AppDomain for namespaces that fit a specific criteria. You can search the entire AppDomain, specific assemblies, or get the namespace of specific types or members.
24+
2125
### [Find-Type](Find-Type.md)
2226

2327
The Find-Type cmdlet searches the AppDomain for .NET classes that match specified criteria.

docs/en-US/Find-Member.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ Find-Member Parse* -ParameterType System.Management.Automation.Language.Token
119119
Find all members that start with the word Parse and take Token as a parameter. This example also
120120
demonstrates how this will even match the element of a type that is both an array and ByRef type.
121121

122-
123122
### -------------------------- EXAMPLE 5 --------------------------
124123

125124
```powershell
@@ -281,6 +280,22 @@ Accept pipeline input: False
281280
Accept wildcard characters: True
282281
```
283282
283+
### -Not
284+
285+
Specifies that this cmdlet should only return object that do not match the criteria.
286+
287+
```yaml
288+
Type: SwitchParameter
289+
Parameter Sets: (All)
290+
Aliases:
291+
292+
Required: False
293+
Position: Named
294+
Default value: None
295+
Accept pipeline input: False
296+
Accept wildcard characters: False
297+
```
298+
284299
### -ParameterType
285300
286301
Specifies a type that a member must accept as a parameter to be matched. This parameter will also match base types, implemented interfaces, and the element type of array, byref, pointer and generic types.
@@ -363,11 +378,13 @@ Accept wildcard characters: False
363378
364379
## INPUTS
365380
366-
### Type, MemberInfo, PSObject
381+
### ClassExplorer.NamespaceInfo, System.Type, System.Reflection.MemberInfo, PSObject
382+
383+
If you pass NamespaceInfo objects to this cmdlet it will match members from types declared in that namespace.
367384
368385
If you pass Type objects to this cmdlet it will match members from that type.
369386
370-
If you pass MemberInfo objects to this cmdlet it will filter them.
387+
If you pass MemberInfo objects as input this cmdlet will return the input if it matches the specified criteria. You can use this to chain Find-Member commands to filter output.
371388
372389
If you pass any other type to this cmdlet it will match members from that object's type.
373390
@@ -382,5 +399,6 @@ Matched MemberInfo objects will be returned to the pipeline.
382399
## RELATED LINKS
383400
384401
[Find-Type](Find-Type.md)
402+
[Find-Namespace](Find-Namespace.md)
385403
[Get-Assembly](Get-Assembly.md)
386404
[Get-Parameter](Get-Parameter.md)

0 commit comments

Comments
 (0)