Windows PowerShell wouldn’t be very useful without all the great cmdlets that actually manage specific technologies. We want to help cmdlet developers to create high-quality cmdlets. Today we announce availability of FxCop rules that can be used to verify compliance with some of the Cmdlet Design Guidelines as well as to find some of the common bugs.
Installation
Use the following procedure to download the required components:
- Download Microsoft FxCop 1.36 from the Microsoft Download Center at http://go.microsoft.com/fwlink/?LinkID=185006.
- Download Microsoft.PowerShell.CodeAnalysis.dll from the MSDN Code Gallery at http://go.microsoft.com/fwlink/?LinkId=185007. Save the file in any location.
Use the following procedure to configure Microsoft FxCop to run FxCop Rules for Windows PowerShell on your code:
- Click Start and then click Microsoft FxCop 1.36.
- From the Project menu, select Add Rules, navigate to the Microsoft.PowerShell.CodeAnalysis.dll file, and click Open.
- From the Project menu, select Add Targets, navigate to the .dll file that implements your cmdlets, and click Open.
- From the Project menu, select Analyze or press F5.
Please refer to the FxCop Rules for Windows PowerShell project on Code Gallery for more details.
List of rules
- AcceptForceParameterWhenCallingShouldContinue
- AllCmdletsShouldAcceptPipelineInput
- CallShouldProcessOnlyIfDeclaringSupport
- DefineCmdletInTheCorrectNamespace
- DoNotAccessPipelineParametersOutsideProcessRecord
- DoNotCallCertainHostMethods
- DoNotUseConsoleApi
- FollowCmdletClassNamingConvention
- OverrideProcessRecordIfAcceptingPipelineInput
- ParameterShouldHaveConsistentTypePerNoun
- UseCredentialAttributeForPSCredentialParameter
- UseOnlyApprovedCharactersInVerbsAndNouns
- UseOnlyStandardVerbs
- UsePascalCasingInVerbsAndNouns
- UseRecommendedParameterTypes
- UseSingularNouns
- UseSingularParameterNames
- UseSwitchParameterInsteadOfBoolean
Thanks,
Lukasz Anforowicz [MSFT]
Windows PowerShell Developer
Microsoft Corporation
0 comments