GeezerVison is showing github.com — Fix error message when 'HelpMessage' property of 'ParameterAttribute'… · PowerShell/PowerShell@0cd7a4a
File tree
Expand file treeCollapse file tree
Open diff view settings
src/System.Management.Automation/engine
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/System.Management.Automation/engine/Attributes.cs +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -686,7 +686,7 @@ public string HelpMessage |
686 | 686 | { |
687 | 687 | if (string.IsNullOrEmpty(value)) |
688 | 688 | { |
689 | | - throw PSTraceSource.NewArgumentException("value"); |
| 689 | + throw PSTraceSource.NewArgumentException("HelpMessage"); |
690 | 690 | } |
691 | 691 | _helpMessage = value; |
692 | 692 | } |
@@ -707,7 +707,7 @@ public string HelpMessageBaseName |
707 | 707 | { |
708 | 708 | if (string.IsNullOrEmpty(value)) |
709 | 709 | { |
710 | | - throw PSTraceSource.NewArgumentException("value"); |
| 710 | + throw PSTraceSource.NewArgumentException("HelpMessageBaseName"); |
711 | 711 | } |
712 | 712 | _helpMessageBaseName = value; |
713 | 713 | } |
@@ -728,7 +728,7 @@ public string HelpMessageResourceId |
728 | 728 | { |
729 | 729 | if (string.IsNullOrEmpty(value)) |
730 | 730 | { |
731 | | - throw PSTraceSource.NewArgumentException("value"); |
| 731 | + throw PSTraceSource.NewArgumentException("HelpMessageResourceId"); |
732 | 732 | } |
733 | 733 | _helpMessageResourceId = value; |
734 | 734 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: src/System.Management.Automation/engine/CommandDiscovery.cs -10Lines changed: 0 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -775,16 +775,6 @@ internal CommandProcessorBase LookupCommandProcessor(CommandInfo commandInfo, |
775 | 775 | new CommandNotFoundException(reqSyntaxException.Message, reqSyntaxException); |
776 | 776 | throw e; |
777 | 777 | } |
778 | | - catch (PSArgumentException argException) |
779 | | - { |
780 | | - CommandNotFoundException e = |
781 | | - new CommandNotFoundException( |
782 | | - commandInfo.Name, |
783 | | - argException, |
784 | | - "ScriptRequiresInvalidFormat", |
785 | | - DiscoveryExceptions.ScriptRequiresInvalidFormat); |
786 | | - throw e; |
787 | | - } |
788 | 778 | break; |
789 | 779 | case CommandTypes.Filter: |
790 | 780 | case CommandTypes.Function: |
|
Collapse file
Copy file name to clipboard +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +Describe "Attribute tests" -Tags "CI" { |
| 2 | + BeforeEach { |
| 3 | + Remove-Item $testdrive/test.ps1 -Force -ErrorAction SilentlyContinue |
| 4 | + } |
| 5 | + |
| 6 | + It "<attribute> attribute returns argument error if empty" -TestCases @( |
| 7 | + @{Attribute="HelpMessage"}, |
| 8 | + @{Attribute="HelpMessageBaseName"}, |
| 9 | + @{Attribute="HelpMessageResourceId"} |
| 10 | + ) { |
| 11 | + param($attribute) |
| 12 | + |
| 13 | + $script = @" |
| 14 | +[CmdletBinding()] |
| 15 | +Param ( |
| 16 | +[Parameter($attribute="")] |
| 17 | +[String]`$Parameter1 |
| 18 | +) |
| 19 | +Write-Output "Hello" |
| 20 | +"@ |
| 21 | + New-Item -Path $testdrive/test.ps1 -Value $script -ItemType File |
| 22 | + { & $testdrive/test.ps1 } | ShouldBeErrorId "Argument" |
| 23 | + } |
| 24 | +} |