Search Wiki:

UseSingularParameterNames


TypeName UseSingularParameterNames
CheckId PS1006
Error-Level Warning
Category Microsoft.PowerShell
Certainty 75%
BreakingChangeDepends on fix
Cause A cmdlet parameter name is a plural noun, but the parameter will accept a single object.
Rule description Do not use plural nouns as parameter names unless the parameter takes only multiple items and will not accept a collection that contains one item.
How to fix violations Change the parameter name to a singular form. To mitigate the resulting breaking change, use an alias that associates the original parameter name with the new name. Parameter aliases can be plural nouns.
When to exclude warnings Plural parameter names are permitted only when the value of the parameter must always be more than one item. When a plural parameter name is used, the cmdlet code must verify that multiple elements are supplied and the cmdlet should display a warning to the user when only one element is supplied.
Related rules UseSingularNouns
See also FxCop Rules for Windows PowerShell

Examples


    [Cmdlet("Write", "String")]
    public class WriteStringCommand : PSCmdlet
    {
        // Rule violation – plural parameter name.
        [Parameter(ValueFromPipeline = true)]
        public string[] InputObjects
        {
            get { return this.inputObject; }
            set { this.inputObject = value; }
        }
        private string[] inputObject;
 
        // ...
    }

Back to FxCop Rules for Windows PowerShell.
Last edited Mar 26 2010 at 5:38 PM  by JuneB, version 1
Updating...
Page view tracker