Search Wiki:

ParameterShouldHaveConsistentTypePerNoun


TypeName ParameterShouldHaveConsistentTypePerNoun
CheckId PS1103
Error-Level Warning
Category Microsoft.PowerShell
Certainty 95%
BreakingChangeDepends on fix
Cause Inconsistent parameter types in cmdlets with the same noun.
Rule description When a parameter appears in multiple cmdlets that have the same noun, the parameter type must be the same in all occurrences of the parameter.
How to fix violations Change the name or type of the affected parameter so that the same parameter type is used in parameters with the same name in all cmdlets with the same noun.
When to exclude warnings Do not suppress warnings from this rule.
Related rules (None)
See also FxCop Rules for Windows PowerShell

Examples


// These cmdlets violate the rule because both have
// an Encoding parameter, but one Encoding parameter takes a 
// value of type String and the other takes a value of type Int.
 
    [Cmdlet("Write", "String")]
    public class WriteStringCommand : PSCmdlet
    {
        [Parameter]
        public string[] Encoding
        {
     // ...
        }
    }
 
    [Cmdlet("Export", "String")]
    public class ExportStringCommand : PSCmdlet
    {
        [Parameter]
        public int32[] Encoding
        {
     // ...
        }
    }
Back to FxCop Rules for Windows PowerShell.
Last edited Mar 26 2010 at 4:21 PM  by JuneB, version 1
Updating...
Page view tracker