{"id":3061,"date":"2010-03-30T10:37:24","date_gmt":"2010-03-30T10:37:24","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2010\/03\/30\/testing-cmdlets-with-fxcop\/"},"modified":"2019-02-18T13:05:58","modified_gmt":"2019-02-18T20:05:58","slug":"testing-cmdlets-with-fxcop","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/testing-cmdlets-with-fxcop\/","title":{"rendered":"Testing cmdlets with FxCop"},"content":{"rendered":"<p>Windows PowerShell wouldn\u2019t be very useful without all the great cmdlets that actually manage specific technologies.&#160; We want to help cmdlet developers to create high-quality cmdlets.&#160; Today we announce availability of FxCop rules that can be used to verify compliance with some of the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms714657(VS.85).aspx\">Cmdlet Design Guidelines<\/a> as well as to find some of the common bugs.<\/p>\n<h4>Installation<\/h4>\n<p>Use the following procedure to download the required components:<\/p>\n<ol>\n<li>Download <b>Microsoft FxCop 1.36<\/b> from the Microsoft Download Center at <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=185006\">http:\/\/go.microsoft.com\/fwlink\/?LinkID=185006<\/a>. <\/li>\n<li>Download <b>Microsoft.PowerShell.CodeAnalysis.dll<\/b> from the MSDN Code Gallery at <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=185007\">http:\/\/go.microsoft.com\/fwlink\/?LinkId=185007<\/a>. Save the file in any location. <\/li>\n<\/ol>\n<p>Use the following procedure to configure Microsoft FxCop to run FxCop Rules for Windows PowerShell on your code:<\/p>\n<ol>\n<li>Click <b>Start<\/b> and then click <b>Microsoft FxCop 1.36<\/b>. <\/li>\n<li>From the <b>Project<\/b> menu, select <b>Add Rules<\/b>, navigate to the <b>Microsoft.PowerShell.CodeAnalysis.dll<\/b> file, and click <b>Open<\/b>. <\/li>\n<li>From the <b>Project<\/b> menu, select <b>Add Targets<\/b>, navigate to the .dll file that implements your cmdlets, and click <b>Open<\/b>. <\/li>\n<li>From the <b>Project<\/b> menu, select <b>Analyze<\/b> or press <b>F5<\/b>. <\/li>\n<\/ol>\n<p>Please refer to the <a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\">FxCop Rules for Windows PowerShell<\/a> project on Code Gallery for more details.<\/p>\n<h4>List of rules<\/h4>\n<ul>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=AcceptForceParameterWhenCallingShouldContinue&amp;referringTitle=Home\">AcceptForceParameterWhenCallingShouldContinue<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=AllCmdletsShouldAcceptPipelineInput&amp;referringTitle=Home\">AllCmdletsShouldAcceptPipelineInput<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=CallShouldProcessOnlyIfDeclaringSupport&amp;referringTitle=Home\">CallShouldProcessOnlyIfDeclaringSupport<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=DefineCmdletInTheCorrectNamespace&amp;referringTitle=Home\">DefineCmdletInTheCorrectNamespace<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=DoNotAccessPipelineParametersOutsideProcessRecord&amp;referringTitle=Home\">DoNotAccessPipelineParametersOutsideProcessRecord<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=DoNotCallCertainHostMethods&amp;referringTitle=Home\">DoNotCallCertainHostMethods<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=DoNotUseConsoleApi&amp;referringTitle=Home\">DoNotUseConsoleApi<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=FollowCmdletClassNamingConvention&amp;referringTitle=Home\">FollowCmdletClassNamingConvention<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=OverrideProcessRecordIfAcceptingPipelineInput&amp;referringTitle=Home\">OverrideProcessRecordIfAcceptingPipelineInput<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=ParameterShouldHaveConsistentTypePerNoun&amp;referringTitle=Home\">ParameterShouldHaveConsistentTypePerNoun<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=UseCredentialAttributeForPSCredentialParameter&amp;referringTitle=Home\">UseCredentialAttributeForPSCredentialParameter<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=UseOnlyApprovedCharactersInVerbsAndNouns&amp;referringTitle=Home\">UseOnlyApprovedCharactersInVerbsAndNouns<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=UseOnlyStandardVerbs&amp;referringTitle=Home\">UseOnlyStandardVerbs<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=UsePascalCasingInVerbsAndNouns&amp;referringTitle=Home\">UsePascalCasingInVerbsAndNouns<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=UseRecommendedParameterTypes&amp;referringTitle=Home\">UseRecommendedParameterTypes<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=UseSingularNouns&amp;referringTitle=Home\">UseSingularNouns<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=UseSingularParameterNames&amp;referringTitle=Home\">UseSingularParameterNames<\/a> <\/li>\n<li><a href=\"http:\/\/code.msdn.microsoft.com\/FxCopPowerShellRules\/Wiki\/View.aspx?title=UseSwitchParameterInsteadOfBoolean&amp;referringTitle=Home\">UseSwitchParameterInsteadOfBoolean<\/a> <\/li>\n<\/ul>\n<p>Thanks,    <\/p>\n<p>Lukasz Anforowicz [MSFT]     <br \/>Windows PowerShell Developer     <br \/>Microsoft Corporation<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows PowerShell wouldn\u2019t be very useful without all the great cmdlets that actually manage specific technologies.&#160; We want to help cmdlet developers to create high-quality cmdlets.&#160; 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 [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3061","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>Windows PowerShell wouldn\u2019t be very useful without all the great cmdlets that actually manage specific technologies.&#160; We want to help cmdlet developers to create high-quality cmdlets.&#160; 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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/3061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=3061"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/3061\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=3061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=3061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=3061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}