-
Notifications
You must be signed in to change notification settings - Fork 383
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
fix #1417 modulehelp false positives #1418
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,15 +214,19 @@ 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. | ||
) | ||
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 | ||
# Because on Windows Powershell we have workflow, we need to include it there, but in pwsh, we can't. This makes sure this works on both. | ||
$commandTypes = ([System.Enum]::GetNames("System.Management.Automation.CommandTypes") -match "^Cmdlet$|^Function$|^Workflow$") | ||
$commands = Get-Command -FullyQualifiedModule $ms -CommandType $commandTypes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
$commands = Get-Command -FullyQualifiedModule $ms I could reproduce the error where it complains about workflows locally and just using the proposed line worked fine as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, makes a lot of sense. will do that. |
||
} | ||
|
||
## When testing help, remember that help is cached at the beginning of each session. | ||
|
@@ -276,7 +280,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 | ||
|
There was a problem hiding this comment.
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.