Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introducing fx cop


Published on

  • Be the first to comment

  • Be the first to like this

Introducing fx cop

  1. 1. Introducing FxCop Practical Help for Code Reviews
  2. 2. Background <ul><li>FxCop is used to analyze code based on the generated assembly regardless of the language </li></ul><ul><li>Automate validation of established standards </li></ul><ul><li>Create rules to validate custom standards and guidelines </li></ul>
  3. 3. Agenda <ul><li>The need for Code Validation </li></ul><ul><li>Using FxCop </li></ul><ul><li>Interpreting the Results </li></ul><ul><li>Reviewing the Existing Rules </li></ul><ul><li>Creating Rules </li></ul><ul><li>Fitting FxCop into the Life Cycle </li></ul>
  4. 4. Why Code Validation <ul><li>Ensure adherence to standards </li></ul><ul><li>Ensure consistency </li></ul><ul><li>Ensure following “Best Practices” </li></ul><ul><li>Give guidance to new team members </li></ul><ul><li>Automate Code Reviews </li></ul>
  5. 5. Coding Standards <ul><li>There are established standards for Class Library Developers </li></ul><ul><ul><li> </li></ul></ul><ul><li>These guidelines are implemented as pre built rules for FxCop </li></ul><ul><li>You can build rules for your own standards </li></ul>
  6. 6. Using FxCop <ul><li>Start the Utility </li></ul><ul><li>Select Assemblies to validate </li></ul><ul><li>Add custom rules if you have them </li></ul><ul><li>Analyze </li></ul><ul><li>Review the results </li></ul><ul><li>Exclude Rules as Appropriate </li></ul><ul><li>Make Code Changes as Appropriate </li></ul><ul><li>Save the FxCop Project </li></ul>
  7. 7. Interpreting the Results <ul><li>Add the “New” Column to track whether an issue is new or not </li></ul><ul><li>Navigate through the “Targets” to find only the violations by type, method, property, etc </li></ul><ul><li>Navigate through the “Rules” to find only the violations for that rule </li></ul><ul><li>“ Jump to Source” to have FxCop try to find the source code </li></ul>
  8. 8. The Standard Rules <ul><li>Design Rules </li></ul><ul><li>Globalization Rules </li></ul><ul><li>Interoperability Rules </li></ul><ul><li>Mobility Rules </li></ul><ul><li>Naming Rules </li></ul><ul><li>Performance Rules </li></ul><ul><li>Portability Rules </li></ul><ul><li>Security Rules </li></ul><ul><li>Usage Rules </li></ul>
  9. 9. Creating Your Own Rules <ul><li>Introspection SDK is not documented! </li></ul><ul><li>Use Reflector to review existing rules </li></ul><ul><li>Find an existing rule that does something similar </li></ul><ul><li>Start with the existing rule and understand how it works </li></ul><ul><li>Mold it to your needs </li></ul>
  10. 10. Fitting FxCop Into Your Life Cycle <ul><li>FxCopCmd is command line utility </li></ul><ul><li>Add FxCopCmd as an External Tool </li></ul><ul><li>Output is sent to the “Output” window </li></ul><ul><li>Run FxCop without leaving the IDE </li></ul><ul><li>Review the output with each build </li></ul>
  11. 11. Adding FxCop as an External Tool
  12. 12. Using FxCop Reports <ul><li>Specify a Style Sheet for the Report </li></ul><ul><li>“ Save Report As” from the File Menu </li></ul><ul><li>View the resulting XML file. May need to save it as “HTML” </li></ul><ul><li>Write your own XSLT to change the format </li></ul><ul><li>Include the report with migration requests </li></ul><ul><li>Include the report with Code Reviews </li></ul><ul><li>Include the report with project documentation </li></ul>
  13. 13. Summary <ul><li>FxCop is used to automate the code review process </li></ul><ul><li>FxCop includes rules for detecting over 200 different defects </li></ul><ul><li>You can create your own rules to validate your own standards </li></ul><ul><li>FxCop easily fits into your development life cycle </li></ul>
  14. 14. Where to Get More Information <ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li> Reflector! </li></ul>