Skip to content

fix #1417 modulehelp false positives #1418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Tests/Engine/ModuleHelp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,17 @@ Get-Module $ModuleName | Remove-Module
Import-Module $ModuleName -RequiredVersion $RequiredVersion -ErrorAction Stop
$ms = $null
$commands =$null
$paramBlackList = @()
$paramBlackList = @(
'AttachAndDebug' # Reason: When building with DEGUG configuration, an additional parameter 'AttachAndDebug' will be added to Invoke-ScriptAnalyzer and Invoke-Formatter, but there is no Help for those, as they are not intended for production usage.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change absolutely makes sense, I could reproduce the failure locally using a debug build. Thanks for taking the time to fix it.

)
if ($PSVersionTable.PSVersion -lt [Version]'5.0.0') {
$ms = New-Object -TypeName 'Microsoft.PowerShell.Commands.ModuleSpecification' -ArgumentList $ModuleName
$commands = Get-Command -Module $ms.Name
$paramBlackList += 'SaveDscDependency'
}
else {
$ms = [Microsoft.PowerShell.Commands.ModuleSpecification]@{ ModuleName = $ModuleName; RequiredVersion = $RequiredVersion }
$commands = Get-Command -FullyQualifiedModule $ms -CommandType Cmdlet,Function,Workflow # Not alias
$commands = Get-Command -FullyQualifiedModule $ms
}

## When testing help, remember that help is cached at the beginning of each session.
Expand Down Expand Up @@ -276,7 +278,7 @@ foreach ($command in $commands) {
$HelpParameterNames = $Help.Parameters.Parameter.Name | Sort-Object -Unique

foreach ($parameter in $parameters) {
if ($parameter -in $paramBlackList) {
if ($parameter.Name -in $paramBlackList) {
continue
}
$parameterName = $parameter.Name
Expand Down