Visual Studio 2008中/ C#:如何找到一个项目死代码? [英] Visual Studio 2008 / C# : How to find dead code in a project?

查看:143
本文介绍了Visual Studio 2008中/ C#:如何找到一个项目死代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何找到在Visual Studio 2008中C#项目死码? ?
类似未使用的类,未使用的变量或者未使用的资源

How do I find dead code in a Visual Studio 2008 C# project? Like unused classes, unused variables or unused resources?

推荐答案

您可以尝试的FxCop 的,这是由代码分析的名称集成在Visual Studio 2008。你只需要右键单击该项目文件和运行代码分析。

You can try FxCop, which is integrated in Visual Studio 2008 by the name of Code Analysis. You just have to right click the project file and 'Run Code Analysis'.

的FxCop是分析托管代码程序集的应用程序(代码面向.NET Framework公共语言运行库),并报告有关组件,如可能的设计,定位,性能和安全方面的改进信息。

FxCop is an application that analyzes managed code assemblies (code that targets the .NET Framework common language runtime) and reports information about the assemblies, such as possible design, localization, performance, and security improvements.

活动规则可以在项目属性的代码分析部分进行配置。例如一些相关的在手的情况下,规则存在于使用规则和性能规则:

The active rules can be configured in the Code Analysis section of the project properties. For example some rules relevant to the case in hand are present in Usage Rules and Performance Rules:


  • CA1801:回顾未使用的参数

  • CA1811:避免不必要的私人代码

和更大的灵活性,也写自己的自定义规则(。编写自己的代码教程分析规则)。

And for greater flexibility you also write your own custom rules (Tutorial on writing your own Code Analysis rule).

这篇关于Visual Studio 2008中/ C#:如何找到一个项目死代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆