如何轻松找到未使用的公共方法/属性 [英] How to easyily find unused public methods/properties

查看:122
本文介绍了如何轻松找到未使用的公共方法/属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.Net(C#)解决方案.该解决方案包含大量项目.这些项目不是我实施的.这不是一个框架,这意味着我需要尽量减少公共方法/属性的数量.我的任务是确定未使用但存在于项目中的方法和属性.好吧,我可以找到不使用R#的私有方法.但是目前还不清楚如何找到未使用的 public 方法/属性.

I have a .Net(C#) solution. The solution contains bunch of projects. The projects were implemented not by me. It is not a framework, it means that I need to have amount of public methods/properties as less as possible. My task is to identify methods and properties which are not used, but exist in the projects. Well, I can find private methods which are not used using R#. But it is completely unclear how to find public methods/properties which are not used.

我听说他们有NDepend工具,但这不是很简单的工具.

I heard that they have NDepend tool, but it is not very simple tool, is it.

所以,问题是:请您指出一个可用于识别解决方案中未使用的方法的工具.我可以使用命令行工具或一些非常简单的工具.

So, the question is: could you please point to a tool which can be used to identify methods which are not used in a solution. It is OK with me to have command line tool or something pretty simple.

UPD:我尝试使用试用版NDepend.

UPD: I tried to use trial NDepend.

好吧,首先,似乎有可能看到未在此特定程序集中使用的公共方法(属性表示为get_ set_方法).

Well, first of all it seems like it is possible to see public methods (properties are represented as get_ set_ methods) which are not used in this particular assembly.

但是NDepend无法识别是否从另一个项目/程序集中使用了公共方法,这是解决方案的一部分,并将该方法显示为未使用.但这不是真的.

But NDepend does not recognize if the public method is used from another project/assembly, which is a part of the solution and shows the method as unused. But this is not true.

UPD2:mcintyre321建议使用R#.请阅读下面的第一条评论.

UPD2: mcintyre321 advised to use R#. Please read a first comment below.

推荐答案

如果您在ReSharper(5.0及更高版本)中启用了解决方案范围的分析,则会为您进行标记.这包括公共方法.

If you turn on solution wide analysis in ReSharper (5.0 and above) it will flag them for you. This includes public methods.

如何启用

这篇关于如何轻松找到未使用的公共方法/属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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