Adding ValidateNotNullOrEmpty attribute to parameters listed in #2672 (#2685)

This commit is contained in:
Dave Wyatt 2016-12-08 13:28:55 -05:00 committed by Jason Shirk
parent 49d5b6ab4f
commit 177c99de93
13 changed files with 14 additions and 2 deletions

View file

@ -28,6 +28,7 @@ namespace Microsoft.PowerShell.Commands
[Alias("ClassName")]
[Parameter(Position = 0, Mandatory = true, ParameterSetName = "query")]
[Parameter(Position = 1, ParameterSetName = "list")]
[ValidateNotNullOrEmpty()]
public string Class { get; set; }
/// <summary>
@ -40,6 +41,7 @@ namespace Microsoft.PowerShell.Commands
/// The WMI properties to retrieve
/// </summary>
[Parameter(Position = 1, ParameterSetName = "query")]
[ValidateNotNullOrEmpty()]
public string[] Property
{
get { return (string[])_property.Clone(); }

View file

@ -4747,6 +4747,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
///
[Parameter(Position = 0, ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty()]
public string[] PSProvider
{
get { return _provider; }

View file

@ -132,6 +132,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
[Parameter(Position = 0,
ParameterSetName = CommonRunspaceCommandBase.RunspaceNameParameterSet)]
[ValidateNotNullOrEmpty()]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public string[] RunspaceName
{

View file

@ -41,7 +41,7 @@ namespace Microsoft.PowerShell.Commands
[Parameter(ParameterSetName = "Variable")]
[Parameter(ParameterSetName = "Command")]
[Parameter(ParameterSetName = "Type")]
[ValidateNotNull]
[ValidateNotNullOrEmpty()]
public string[] Script
{
get

View file

@ -21,6 +21,7 @@ namespace Microsoft.PowerShell.Commands
/// An identifier for this event subscription
/// </summary>
[Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ParameterSetName = "BySource")]
[ValidateNotNullOrEmpty()]
public string SourceIdentifier
{
get

View file

@ -21,6 +21,7 @@ namespace Microsoft.PowerShell.Commands
/// An identifier for this event subscription
/// </summary>
[Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ParameterSetName = "BySource")]
[ValidateNotNullOrEmpty()]
public string SourceIdentifier
{
get

View file

@ -34,6 +34,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
[Parameter(Position = 0,
ParameterSetName = GetRunspaceCommand.NameParameterSet)]
[ValidateNotNullOrEmpty()]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public string[] Name
{

View file

@ -258,7 +258,7 @@ namespace Microsoft.PowerShell.Commands
/// Name of the PSVariable
/// </summary>
[Parameter(Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
[ValidateNotNull]
[ValidateNotNullOrEmpty()]
public string[] Name
{
get

View file

@ -22,6 +22,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
/// <value></value>
[Parameter(Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty()]
public string[] Name
{
get

View file

@ -56,6 +56,7 @@ namespace Microsoft.PowerShell.Commands
/// Gets and sets the user supplied username to be used while creating the PSCredential.
/// </summary>
[Parameter(Position = 0, Mandatory = false, ParameterSetName = messageSet)]
[ValidateNotNullOrEmpty()]
public string UserName
{
get { return _userName; }

View file

@ -2824,6 +2824,7 @@ $args[0] | foreach {{
/// </summary>
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
[Parameter(Position = 0, Mandatory = false)]
[ValidateNotNullOrEmpty()]
public string[] Name { get; set; }
/// <summary>

View file

@ -51,6 +51,7 @@ namespace Microsoft.PowerShell.Commands
/// Target to search for help
/// </summary>
[Parameter(Position = 0, ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty()]
public string Name { get; set; } = "";
/// <summary>

View file

@ -712,6 +712,7 @@ namespace Microsoft.PowerShell.Commands
/// Name(s) of PSSnapIn(s).
/// </summary>
[Parameter(Position = 0, Mandatory = false)]
[ValidateNotNullOrEmpty()]
public string[] Name
{
get