Skip to content
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

Do not use alias name as key for command info cache to fix the problem where UseCorrectCasing corrects aliases #1216

Conversation

bergmeister
Copy link
Collaborator

@bergmeister bergmeister commented Apr 13, 2019

PR Summary

Fixes PowerShell/vscode-powershell#1842
Because aliases were used as the key for the cache, once those entities are created, it caused the UseCorrectCasing rule to correct aliases, somehow those cache entries could only be populated when and lead to this behaviour when being used via the vscode extension so I assume it must the some of the commands being issued at startup that cause other rules to populate this entry
Writing a test for this turned out to be hard as only when being used via the PowerShell vscode extension, alias key entries were populated in PSSA's command info cache first.
The intention is to have this PR fix the root cause and another PR to a bit of a cleanup.

PR Checklist

// If alias name is given, we store the entry under that, but search with the command name
var key = new CommandLookupKey(aliasName ?? commandName, commandTypes);

var key = new CommandLookupKey(commandName, commandTypes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If aliasName is unused, maybe time to remove it from the parameters?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done, I also removed the left-over GetCommandInfoInternal function that we moved into the CommandInfoCache a few weeks ago but forgot to delete.
I plan to do another PR with more general tidy up later btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cmdlet aliases are expanded automatically when formatting document
2 participants