PowerShell / PowerShell/PSScriptAnalyzer

Function 'GetCommandInfo' does not add CommandInfo to cache

Open
#1,030 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area - Rules Issue - Bug
Dominant language
C#
Stars
2.2k
Forks
414
Avg merge
13h 1m
Merged PRs (30d)
2

Description

In Helper.cs, the function GetCommandInfo checks the commandInfoCache for a given command, and - if it does not exist in the cache - retrieves the info from a powershell session. Unlike in the deprecated function GetCommandInfoLegacy, however the command info is never added to the commandInfoCache dictionary. (Compare lines 750 and 776)

I'd like to open a PR to correct this, assuming this is indeed a bug.

This should help marginally with performance issues due to contentions from the locks in the GetCommandInfo and GetCommandInfoLegacy functions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Helper.cs at GetCommandInfo and compare its cache path with GetCommandInfoLegacy, particularly the referenced lines around 750 and 776. Confirm that a retrieved command's CommandInfo is added to commandInfoCache; done means the cache is populated consistently with the legacy path.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.