如何找到所有未使用的成员或对象 [英] How to find all unused members or objects

查看:147
本文介绍了如何找到所有未使用的成员或对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要尽量让代码审查走快一点。而在VS,在一个特定的类或.aspx页面中,或不管它是什么,我可以用鼠标右键单击一个变量,方法,属性和使用查找用法,这仍然是一个非常手动过程,我不想就这样做每一个方法,属性等页面......因为很可能没有改变的。



那么,有没有快速的方法来给我的故障列表在页面上,引用,开发人员创建,并且可以在同一时间使用,但使用它,忘记清理停止?



不知道的最好的方式得到一些各类报表背后,可能显示此每页甚至每个项目...


解决方案

ReSharper的可以做到这一点。

HTTP://www.jetbrains。 COM / ReSharper的/功能/ newfeatures.html




这些检查帮助您发现:




  • 未使用非专用报关单

  • 非私有方法

  • 未使用的返回值
  • Unaccessed非 - 私人领域

  • 在非私有成员未使用的参数

  • 从不会调用抽象的或虚拟的事件

  • 未分配领域

  • 成员和类型,可以进行,而不是公开



您可以设置提示或警告错误的内联。



有关每个警告你看到点击它,然后按Alt + Enter。你应该得到,说一个菜单项检查选项...。
选择一个,并设置错误。



您可以更改多个严重性错误



菜单ReSharper的>选项>检验严重性



有些你可能想使误差




  • 不用于分配

  • 类从不实例

  • 方法返回值是从来没有使用过

  • Unaccessed场

  • 未decleration

  • 未使用的类型参数



打开sultion广泛的错误报告



看到小灰点在VS的右下角
假设它被关闭这将是灰色的。双击它,然后单击对话框上的确定。


I want to try to make code reviews go a bit faster. While in VS, on a particular class or .aspx page or whatever it is, I can right-click a variable, method, property and use the Find Usages, that's still a very manual process and I wouldn't want to do this on every single method, property, etc. on a page...because most probably have not been changed.

So is there a quick way to give me a list of faults on a page, references that the developer created and may used at one time, but stopped using it and forgets to clean up?

Not sure of the best way to get some kind of report back that could show me this per page or even per project...

解决方案

Resharper can do this

From http://www.jetbrains.com/resharper/features/newfeatures.html

These inspections help you discover:

  • Unused non-private declarations
  • Unused return values of non-private methods
  • Unaccessed non-private fields
  • Unused parameters in non-private members
  • Abstract or virtual events that are never invoked
  • Unassigned fields
  • Members and types that can be made internal instead of public

You can set a hint or warning to error inline.

For each warning u see click on it and then press "Alt+enter". You should get a menu item that says "Inspection options for...". Choose that and set it to error.

You can change multiple severities to error

menu Resharper>Options>Inspection Severity

Some you might want to make errors are

  • Assignment is not used
  • Class is never instantiated
  • Method return value is never used
  • Unaccessed Field
  • Unused decleration
  • Unused type parameter

Turn on sultion wide error reporting

See the little grey dot in the bottom right hand corner of VS. Assuming it is turned off it will be grey. Double click it and then click OK on the dialog.

这篇关于如何找到所有未使用的成员或对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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