-
Notifications
You must be signed in to change notification settings - Fork 8.2k
CommandInfo.ResolveParameter throws NullReferenceException sometimes #13127
Copy link
Copy link
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
From PowerShell/PSScriptAnalyzer#1538.
PSScriptAnalyzer tries to get the value of Export-ModuleMember's parameters by calling the CommandInfo.ResolveParameter() call here.
This calls into PowerShell here:
PowerShell/src/System.Management.Automation/engine/CommandInfo.cs
Lines 593 to 605 in b1e9980
| /// <summary> | |
| /// Resolves a full, shortened, or aliased parameter name to the actual | |
| /// cmdlet parameter name, using PowerShell's standard parameter resolution | |
| /// algorithm. | |
| /// </summary> | |
| /// <param name="name">The name of the parameter to resolve.</param> | |
| /// <returns>The parameter that matches this name.</returns> | |
| public ParameterMetadata ResolveParameter(string name) | |
| { | |
| MergedCommandParameterMetadata merged = GetMergedCommandParameterMetadataSafely(); | |
| MergedCompiledCommandParameter result = merged.GetMatchingParameter(name, true, true, null); | |
| return this.Parameters[result.Parameter.Name]; | |
| } |
As with various other CommandInfo members, this appears not to be threadsafe and the call sometimes throws an NRE.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime