introducing fx cop
TRANSCRIPT
![Page 1: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/1.jpg)
Introducing FxCopIntroducing FxCopPractical Help for Code Reviews
![Page 2: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/2.jpg)
BackgroundBackground
FxCop is used to analyze code based on the generated assembly regardless of the language
Automate validation of established standards
Create rules to validate custom standards and guidelines
![Page 3: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/3.jpg)
AgendaAgenda
The need for Code ValidationUsing FxCopInterpreting the ResultsReviewing the Existing RulesCreating RulesFitting FxCop into the Life Cycle
![Page 4: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/4.jpg)
Why Code ValidationWhy Code Validation
Ensure adherence to standardsEnsure consistencyEnsure following “Best Practices”Give guidance to new team membersAutomate Code Reviews
![Page 5: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/5.jpg)
Coding StandardsCoding Standards
There are established standards for Class Library Developers– http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/cpgenref/html/cpconnetframeworkdesignguidelines.asp
These guidelines are implemented as pre built rules for FxCop
You can build rules for your own standards
![Page 6: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/6.jpg)
Using FxCopUsing FxCop
Start the UtilitySelect Assemblies to validateAdd custom rules if you have themAnalyze Review the resultsExclude Rules as AppropriateMake Code Changes as AppropriateSave the FxCop Project
![Page 7: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/7.jpg)
Interpreting the ResultsInterpreting the Results
Add the “New” Column to track whether an issue is new or not
Navigate through the “Targets” to find only the violations by type, method, property, etc
Navigate through the “Rules” to find only the violations for that rule
“Jump to Source” to have FxCop try to find the source code
![Page 8: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/8.jpg)
The Standard RulesThe Standard Rules
Design Rules Globalization Rules Interoperability Rules Mobility Rules Naming Rules Performance Rules Portability Rules Security Rules Usage Rules
![Page 9: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/9.jpg)
Creating Your Own RulesCreating Your Own Rules
Introspection SDK is not documented!Use Reflector to review existing rulesFind an existing rule that does something
similarStart with the existing rule and understand
how it worksMold it to your needs
![Page 10: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/10.jpg)
Fitting FxCop Into Your Life CycleFitting FxCop Into Your Life Cycle
FxCopCmd is command line utilityAdd FxCopCmd as an External ToolOutput is sent to the “Output” windowRun FxCop without leaving the IDEReview the output with each build
![Page 11: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/11.jpg)
Adding FxCop as an External ToolAdding FxCop as an External Tool
![Page 12: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/12.jpg)
Using FxCop ReportsUsing FxCop Reports
Specify a Style Sheet for the Report “Save Report As” from the File Menu View the resulting XML file. May need to save
it as “HTML” Write your own XSLT to change the format Include the report with migration requests Include the report with Code Reviews Include the report with project documentation
![Page 13: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/13.jpg)
SummarySummary
FxCop is used to automate the code review process
FxCop includes rules for detecting over 200 different defects
You can create your own rules to validate your own standards
FxCop easily fits into your development life cycle
![Page 14: Introducing fx cop](https://reader030.vdocuments.mx/reader030/viewer/2022012902/55526b4bb4c905d41d8b511c/html5/thumbnails/14.jpg)
Where to Get More InformationWhere to Get More Information
http://aspnet.4guysfromrolla.com/articles/060204-1.aspx http://www.futureware.biz/blog/index.php?
title=writing_your_own_fxcop_rules_library http://msdn.microsoft.com/msdnmag/issues/04/09/Bugslayer/ http://www.biasecurities.com/blogs/jim/archive/
2004/12/29/818.aspx http://www.gotdotnet.com/team/fxcop/ http://blogs.msdn.com/fxcop/archive/2004/01/09/49287.aspx http://www.gotdotnet.com/team/fxcop/docs/UsingFxCop.htm http://www.geekswithblogs.net/nharrison http://www.aisto.com/roeder/dotnet/ Reflector!