-
Notifications
You must be signed in to change notification settings - Fork 407
Warn when 'Get-' prefix was omitted. #927
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
Merged
bergmeister
merged 8 commits into
PowerShell:development
from
bergmeister:WarnWhenGetPrefixWasOmitted
Mar 28, 2018
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
26003b3
Warn when 'Get-' prefix was omitted. Rename some variables to make th…
bergmeister dd87390
update docs
bergmeister 9b1da90
do not warn for get- completion when the command exists natively (e.g…
bergmeister db0c195
add test that there are no warnings about get- completion when native…
bergmeister 59fae3b
use `date` for test because on some MacOs distros, service is not ava…
bergmeister 6e79eec
Fix GetCommandInfoInternal method to actually use the CommandTypes ar…
bergmeister 0dea943
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister 31055fd
change test syntax as requested in PR
bergmeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
do not warn for get- completion when the command exists natively (e.g…
…. 'date' or service' on Unix systems)
- Loading branch information
commit 9b1da90343e18f38fca9065a7669b6bf82790276
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessarily a native command, but it's anything that will be returned by
Get-Command. I was thinking that this was a bit open and wanted to be more specific about native apps, and there is an overload for GetCommandInfo which takes a CommandType, which would be perfect, because we could do this:var isNativeCommand = Helper.Instance.GetCommandInfo(commandName, (CommandTypes.Application|CommandTypes.ExternalScript))unfortunately, the internal method doesn't actually use this parameter if it's passed in which is a bug - grrrr
The reason I'm worried is that we may be still casting too broad a net here, and we'll get more false positives as the call as written will find everything named 'date' including scripts/functions/etc.
The long and short of it is there's no way to return just the native apps with the bug in the engine, so this may generate false positives. So the name of the variable is not what it purports to be (a native command)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it turns out that lots of other code seems to be indirectly relying on this bug and other things start to break if I were to fix it. I fixed therefore only the
GetCommandInfoInternalmethod to actually use theCommandTypesargument and declared the oldGetCommandInfomethod as legacy to not break existing behaviour. I think this bad behaviour is mainly due to the commandInfo cache, which is one of too many shared static members that are indirectly being modified. I re-ran the tests locally on an Ubuntu 16 VM.