Tag: Visual Studio

Visual Studio Code Metrics

How to Generate Code Metrics Data

  • Click Analysis menu, then click Calculate Code Metrics for Solution

1. Maintainability Index
+ Measures ease of code maintenance. Higher values are better.
+ No individual method or property should have a maintainability index lower than 40

2. Cyclomatic Complexity
+ Measures number of branches. Lower values are better.
+ No individual method or property should have a cyclomatic complexity greater than 10

3. Depth of Inheritance
+ Measures length of object inheritance hierarchy. Lower values are better.
+ No individual type should have object inheritance hierarchy greater than 4

4. Class Coupling
+ Measures number of classes that are referenced. Lower values are better.
+ No individual type, method or property should have class coupling greater than 10

5. Lines of Code
+ Approximates the lines of executable code (IL code). Lower values are better.
+ Not a good measure by itself


Microsoft Code Analysis Tool .NET (CAT.NET)

CAT.NET is a binary code analysis tool that helps identify common variants of certain prevailing vulnerabilities that can give rise to common attack vectors such as Cross-Site Scripting (XSS), SQL Injection and XPath Injection.

Using CAT.NET in Visual Studio 2010

By default, CAT.NET v1 cannot be run in Visual Studio 2010. The following tweak can be used to enable CAT.NET v1 in Visual Studio 2010.

  1. In notepad, open file %APPDATA%\Microsoft\MSEnvShared\Addins\Microsoft.ACESec.CATNet.AddIn
  2. Add a line “<Version>10.0</Version>” below the line “<Version>9.0</Version>”
  3. Open Visual Studio 2010, and navigate to Tools –> CAT.NET Code Analysis

SQL Server Database Project

  1. On the File menu, point to New, and then click Project to add SQL Server 2008 Database Project to the existing solution.
  2. On the Data menu, point to Schema Compare, and then click New Schema Comparison.
  3. In the Source Schema panel, select Database, and then click New Connection to connect to the data source.
  4. In the Target Schema panel, select Project, and then select the Database Project.
  5. Click OK to start Schema Comparison.
  6. After the comparison finishes, a table in the Schema Compare window lists the database objects that were compared.
  7. To update the schema to the target Database Project, click Write Updates button in the Schema Compare toolbar.
  8. You can save the created Schema Comparison for later use.