-
-
Notifications
You must be signed in to change notification settings - Fork 473
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 module import performance regression #2336
Conversation
Require internal flag to add parameter help for built-in Should-operators. Only used by command ref-script in docs-repo and increased import time by 3-4sec in inline build. See pester#2335
Ideally we'd use external help (and markdown as source?), but that requires cleanup here and docs-repo (incl. Alt3.Docusaurus.PowerShell module) so need to discuss it first. That should also improve speed of |
src/Main.ps1
Outdated
$ParameterAttribute.HelpMessage = 'The name of the assertion/operator' | ||
$AttributeCollection.Add($ParameterAttribute) | ||
|
||
$ValidateSetAttribute = & $SafeCommands['New-Object']System.Management.Automation.ValidateSetAttribute($script:AssertionOperators.Keys) |
Check notice
Code scanning / PSScriptAnalyzer
The built-in *-Object-cmdlets are slow compared to alternatives in .NET. To fix a violation of this rule, consider using an alternative like `foreach/for`-keyword etc.`.
src/Main.ps1
Outdated
$ValidateSetAttribute = & $SafeCommands['New-Object']System.Management.Automation.ValidateSetAttribute($script:AssertionOperators.Keys) | ||
$AttributeCollection.Add($ValidateSetAttribute) | ||
|
||
$RuntimeParameter = & $SafeCommands['New-Object'] System.Management.Automation.RuntimeDefinedParameter($ParameterName, [string], $AttributeCollection) |
Check notice
Code scanning / PSScriptAnalyzer
The built-in *-Object-cmdlets are slow compared to alternatives in .NET. To fix a violation of this rule, consider using an alternative like `foreach/for`-keyword etc.`.
src/Main.ps1
Outdated
) | ||
DynamicParam { | ||
$ParameterName = 'OperatorName' | ||
$RuntimeParameterDictionary = & $SafeCommands['New-Object'] System.Management.Automation.RuntimeDefinedParameterDictionary |
Check notice
Code scanning / PSScriptAnalyzer
The built-in *-Object-cmdlets are slow compared to alternatives in .NET. To fix a violation of this rule, consider using an alternative like `foreach/for`-keyword etc.`.
src/Main.ps1
Outdated
DynamicParam { | ||
$ParameterName = 'OperatorName' | ||
$RuntimeParameterDictionary = & $SafeCommands['New-Object'] System.Management.Automation.RuntimeDefinedParameterDictionary | ||
$AttributeCollection = & $SafeCommands['New-Object'] System.Collections.ObjectModel.Collection[System.Attribute] |
Check notice
Code scanning / PSScriptAnalyzer
The built-in *-Object-cmdlets are slow compared to alternatives in .NET. To fix a violation of this rule, consider using an alternative like `foreach/for`-keyword etc.`.
src/Main.ps1
Outdated
$ParameterName = 'OperatorName' | ||
$RuntimeParameterDictionary = & $SafeCommands['New-Object'] System.Management.Automation.RuntimeDefinedParameterDictionary | ||
$AttributeCollection = & $SafeCommands['New-Object'] System.Collections.ObjectModel.Collection[System.Attribute] | ||
$ParameterAttribute = & $SafeCommands['New-Object'] System.Management.Automation.ParameterAttribute |
Check notice
Code scanning / PSScriptAnalyzer
The built-in *-Object-cmdlets are slow compared to alternatives in .NET. To fix a violation of this rule, consider using an alternative like `foreach/for`-keyword etc.`.
PR Summary
Fix module import perf regression in 5.4.0 (went from <1 sec to 4sec) caused by slow
Get-Help
calls introduced in #2170.Affected inline-builds (releases) primarily because
Get-Help
reparses the whole command source (17k+ lines psm1 when inline) to get comment-based help. See #2335This PR replaces the code with an internal function to set the help-message.
PR also includes a minor update to help-text for operator-specific parameters.
Fix #2335
PR Checklist
Create Pull Request
to mark it as a draft. PR can be markedReady for review
when it's ready.