From 7b36aead34f706d724a7923972962aa9e7132940 Mon Sep 17 00:00:00 2001 From: sethvs Date: Thu, 26 Jul 2018 12:56:10 +0300 Subject: [PATCH 1/2] Change parameters order in Get-Help and help in order to get first -Full and then -Functionality when using Get-Help -Fu and help -Fu. --- .../engine/InitialSessionState.cs | 18 ++++---- .../help/HelpCommands.cs | 42 +++++++++---------- .../TabCompletion/TabCompletion.Tests.ps1 | 12 ++++++ 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index 51600d157da..8138bd08031 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4213,15 +4213,6 @@ .FORWARDHELPCATEGORY Cmdlet [string[]] ${Category}, - [string[]] - ${Component}, - - [string[]] - ${Functionality}, - - [string[]] - ${Role}, - [Parameter(ParameterSetName='DetailedView', Mandatory=$true)] [switch] ${Detailed}, @@ -4238,6 +4229,15 @@ .FORWARDHELPCATEGORY Cmdlet [string] ${Parameter}, + [string[]] + ${Component}, + + [string[]] + ${Functionality}, + + [string[]] + ${Role}, + [Parameter(ParameterSetName='Online', Mandatory=$true)] [switch] ${Online}, diff --git a/src/System.Management.Automation/help/HelpCommands.cs b/src/System.Management.Automation/help/HelpCommands.cs index 1ddfe090604..20cc8052972 100644 --- a/src/System.Management.Automation/help/HelpCommands.cs +++ b/src/System.Management.Automation/help/HelpCommands.cs @@ -68,27 +68,6 @@ public GetHelpCommand() IgnoreCase = true)] public string[] Category { get; set; } - /// - /// List of Component's to search on. - /// - /// - [Parameter] - public string[] Component { get; set; } = null; - - /// - /// List of Functionality's to search on. - /// - /// - [Parameter] - public string[] Functionality { get; set; } = null; - - /// - /// List of Role's to search on. - /// - /// - [Parameter] - public string[] Role { get; set; } = null; - private string _provider = string.Empty; /// @@ -180,6 +159,27 @@ public SwitchParameter Examples [Parameter(ParameterSetName = "Parameters", Mandatory = true)] public string Parameter { set; get; } + /// + /// List of Component's to search on. + /// + /// + [Parameter] + public string[] Component { get; set; } = null; + + /// + /// List of Functionality's to search on. + /// + /// + [Parameter] + public string[] Functionality { get; set; } = null; + + /// + /// List of Role's to search on. + /// + /// + [Parameter] + public string[] Role { get; set; } = null; + /// /// This parameter,if true, will direct get-help cmdlet to /// navigate to a URL (stored in the command MAML file under diff --git a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 index 505b11d87eb..2ab0e139e58 100644 --- a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 +++ b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 @@ -128,6 +128,18 @@ Describe "TabCompletion" -Tags CI { $res.CompletionMatches[0].CompletionText | Should -Be 'namespace' } + It 'Should first suggest -Full and then -Functionalty when using Get-Help -Fu' -skip { + $res = TabExpansion2 -inputScript 'Get-Help -Fu' -cursorColumn 'Get-Help -Fu'.Length + $res.CompletionMatches[0].CompletionText | Should -Be '-Full' + $res.CompletionMatches[1].CompletionText | Should -Be '-Functionality' + } + + It 'Should first suggest -Full and then -Functionalty when using help -Fu' -skip { + $res = TabExpansion2 -inputScript 'help -Fu' -cursorColumn 'help -Fu'.Length + $res.CompletionMatches[0].CompletionText | Should -Be '-Full' + $res.CompletionMatches[1].CompletionText | Should -Be '-Functionality' + } + Context NativeCommand { BeforeAll { $nativeCommand = (Get-Command -CommandType Application -TotalCount 1).Name From 658ce7a2e156543ebfc9bddfd3311a715dfb8f23 Mon Sep 17 00:00:00 2001 From: sethvs Date: Fri, 27 Jul 2018 10:16:53 +0300 Subject: [PATCH 2/2] Implement requested changes. --- .../help/HelpCommands.cs | 15 ++++++--------- .../Host/TabCompletion/TabCompletion.Tests.ps1 | 12 ++++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/System.Management.Automation/help/HelpCommands.cs b/src/System.Management.Automation/help/HelpCommands.cs index 20cc8052972..b9a40818b51 100644 --- a/src/System.Management.Automation/help/HelpCommands.cs +++ b/src/System.Management.Automation/help/HelpCommands.cs @@ -160,25 +160,22 @@ public SwitchParameter Examples public string Parameter { set; get; } /// - /// List of Component's to search on. + /// Gets and sets list of Component's to search on. /// - /// [Parameter] - public string[] Component { get; set; } = null; + public string[] Component { get; set; } /// - /// List of Functionality's to search on. + /// Gets and sets list of Functionality's to search on. /// - /// [Parameter] - public string[] Functionality { get; set; } = null; + public string[] Functionality { get; set; } /// - /// List of Role's to search on. + /// Gets and sets list of Role's to search on. /// - /// [Parameter] - public string[] Role { get; set; } = null; + public string[] Role { get; set; } /// /// This parameter,if true, will direct get-help cmdlet to diff --git a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 index 2ab0e139e58..5d9944a0714 100644 --- a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 +++ b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 @@ -128,16 +128,16 @@ Describe "TabCompletion" -Tags CI { $res.CompletionMatches[0].CompletionText | Should -Be 'namespace' } - It 'Should first suggest -Full and then -Functionalty when using Get-Help -Fu' -skip { + It 'Should first suggest -Full and then -Functionality when using Get-Help -Fu' -skip { $res = TabExpansion2 -inputScript 'Get-Help -Fu' -cursorColumn 'Get-Help -Fu'.Length - $res.CompletionMatches[0].CompletionText | Should -Be '-Full' - $res.CompletionMatches[1].CompletionText | Should -Be '-Functionality' + $res.CompletionMatches[0].CompletionText | Should -BeExactly '-Full' + $res.CompletionMatches[1].CompletionText | Should -BeExactly '-Functionality' } - It 'Should first suggest -Full and then -Functionalty when using help -Fu' -skip { + It 'Should first suggest -Full and then -Functionality when using help -Fu' -skip { $res = TabExpansion2 -inputScript 'help -Fu' -cursorColumn 'help -Fu'.Length - $res.CompletionMatches[0].CompletionText | Should -Be '-Full' - $res.CompletionMatches[1].CompletionText | Should -Be '-Functionality' + $res.CompletionMatches[0].CompletionText | Should -BeExactly '-Full' + $res.CompletionMatches[1].CompletionText | Should -BeExactly '-Functionality' } Context NativeCommand {