Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 6 src/System.Management.Automation/engine/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ public string HelpMessage
{
if (string.IsNullOrEmpty(value))
{
throw PSTraceSource.NewArgumentException("value");
throw PSTraceSource.NewArgumentException("HelpMessage");
}
_helpMessage = value;
}
Expand All @@ -707,7 +707,7 @@ public string HelpMessageBaseName
{
if (string.IsNullOrEmpty(value))
{
throw PSTraceSource.NewArgumentException("value");
throw PSTraceSource.NewArgumentException("HelpMessageBaseName");
}
_helpMessageBaseName = value;
}
Expand All @@ -728,7 +728,7 @@ public string HelpMessageResourceId
{
if (string.IsNullOrEmpty(value))
{
throw PSTraceSource.NewArgumentException("value");
throw PSTraceSource.NewArgumentException("HelpMessageResourceId");
}
_helpMessageResourceId = value;
}
Expand Down
10 changes: 0 additions & 10 deletions 10 src/System.Management.Automation/engine/CommandDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,16 +775,6 @@ internal CommandProcessorBase LookupCommandProcessor(CommandInfo commandInfo,
new CommandNotFoundException(reqSyntaxException.Message, reqSyntaxException);
throw e;
}
catch (PSArgumentException argException)
{
CommandNotFoundException e =
new CommandNotFoundException(
commandInfo.Name,
argException,
"ScriptRequiresInvalidFormat",
DiscoveryExceptions.ScriptRequiresInvalidFormat);
throw e;
}
break;
case CommandTypes.Filter:
case CommandTypes.Function:
Expand Down
24 changes: 24 additions & 0 deletions 24 test/powershell/engine/Attributes.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Describe "Attribute tests" -Tags "CI" {
BeforeEach {
Remove-Item $testdrive/test.ps1 -Force -ErrorAction SilentlyContinue
}

It "<attribute> attribute returns argument error if empty" -TestCases @(
@{Attribute="HelpMessage"},
@{Attribute="HelpMessageBaseName"},
@{Attribute="HelpMessageResourceId"}
) {
param($attribute)

$script = @"
[CmdletBinding()]
Param (
[Parameter($attribute="")]
[String]`$Parameter1
)
Write-Output "Hello"
"@
New-Item -Path $testdrive/test.ps1 -Value $script -ItemType File
{ & $testdrive/test.ps1 } | ShouldBeErrorId "Argument"
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.