Change CommandInfo lookup for commands in the form module\cmdletName#2125
Conversation
andyleejordan
left a comment
There was a problem hiding this comment.
Perfect, thanks so much! Weird, seems like there may be a bug in Get-Command itself because that behavior is changing between the module-qualified command name, and passing the module name as a separate parameter. Maybe a sorting issue, we don't know. This is a good workaround given your tests.
|
@liamjpeters can you rebase this so the PR checks trigger and I can merge it? Thanks! |
…rm module\cmdletName
dc8786e to
8bde45d
Compare
|
My Git-Fu is not strong @andyleejordan 😅 Did I do it? |
|
You did it! CI Tests are running now 😄 |
|
If only it had succeeded. Drat. The offending test that failed on the mac build runner: PSScriptAnalyzer/Tests/Rules/UseCorrectCasing.tests.ps1 Lines 77 to 85 in ea70855 I don't have a mac to try it on, but the failure looks like the runspace safety issue with the command info cache - an old discussion and summary in issue #1867. I've run the test in a loop and managed to get it to fail once with the same error on my Windows machine after about 20 mins of running. I've managed the same on the master branch just now:
I'm not sure how to check whether this PR makes this issue more prevalent or if it's the same as it has been and just got unlucky with the CI run. |
|
That seems like it's a flaky test, I'm rerunning the CI. |

PR Summary
When the
CommandInfoCacheis used to lookup some fully qualified commands (by way ofGet-Command), a nested module name is returned.PR changes
CommandInfoCachewhen aCommandInfois looked up for a command in the formmodule\cmdletName. It passes this module name hint along toGet-Commandto allow correct resolution.With the
MicrosoftTeamsmodule installed, as an example, running:Reports the commands module as
Microsoft.Teams.ConfigAPI.Cmdlets.Instead running:
Correctly reports the module as
MicrosoftTeams.Also happens for
Az.resources\Get-AzRoleEligibilityScheduleFixes #2123
Fixes #2023
PR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.