visual-studio Visual Studio 解决方案中的类数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/94084/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Number of Classes in a Visual Studio Solution
提问by lyngbym
Is there an easy way to find the number of classes contained within a visual studio solution? Other than writing a funky find script, I couldn't find a way to do it within the code metrics piece of VS.
有没有一种简单的方法可以找到 Visual Studio 解决方案中包含的类的数量?除了编写一个时髦的查找脚本之外,我找不到在 VS 的代码度量部分中执行此操作的方法。
I am running Visual Studio 2008 and this is a VB.Net project through and through.
我正在运行 Visual Studio 2008,这是一个彻头彻尾的 VB.Net 项目。
thanks!
谢谢!
采纳答案by scott.caligan
You could use a free tool like SourceMonitor, which has a reasonable set of metrics including number of classes. You could also use a tool like NDependwhich is a lot more powerful, but also costs money. Either can be integrated into your build environment if you're using MSBuild or NAnt.
您可以使用像SourceMonitor这样的免费工具,它有一组合理的指标,包括类的数量。您也可以使用像NDepend这样的工具,它功能更强大,但也需要花钱。如果您使用 MSBuild 或 NAnt,它们都可以集成到您的构建环境中。
回答by JRoppert
Don't know a direct way but maybe this will help you:
不知道直接的方法,但也许这会帮助你:
- Open MainMenu/View/Other Windows/Code Metric Results
- Calculate Code Metrics Results
- Export the Results to Excel
- Use Excel to get the count of unique Types in the List.
- 打开 MainMenu/View/Other Windows/Code Metric Results
- 计算代码度量结果
- 将结果导出到 Excel
- 使用 Excel 获取列表中唯一类型的计数。
Don't know if the Code Metrics Stuff is available in all Editions of VS. I'm using the Team Suite Edition.
不知道 Code Metrics Stuff 是否在 VS 的所有版本中都可用。我正在使用团队套件版。
回答by Velimir
Open the solution and search in all files " class " (with the white space before and after the word class). This will find all lines like:
public class A : B
The result should be something like
Matching lines: 2887Matching files: 2271 Total files searched: 2486
The first number is the one you are searching for.
打开解决方案,在所有文件中搜索“class”(类前后有空格)。这将找到所有类似的行:
public class A : B
结果应该类似于
匹配行:2887匹配文件:2271 搜索的文件总数:2486
第一个数字是您要搜索的数字。
回答by Andrew Burgess
I haven't used these tools before, but they probably have some facility that can help you. Basically any code metrics package can help. VS 2008 was supposed to have a built in code metrics tool, but I think it was nixed for one reason or another.
我以前没有使用过这些工具,但它们可能有一些可以帮助你的工具。基本上任何代码度量包都可以提供帮助。VS 2008 应该有一个内置的代码度量工具,但我认为它出于某种原因被取消了。
- CodeMetrics Plugin for Reflector
- NDepend- commercial I think, though has a trial download
- 反射器的 CodeMetrics 插件
- NDepend- 我认为是商业的,虽然有试用版下载
--Edit--
JRoppert is correct. I actually remember reading that the metrics tool was only available in the Team edition, not in Pro or Express
--编辑
--JRoppert 是正确的。我实际上记得读过度量工具仅在 Team 版中可用,在 Pro 或 Express 中不可用

