.net 在 Visual Studio 中计算代码行数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3941444/
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
Count Code Lines Number in Visual Studio
提问by serhio
One team will analyze our .NET project(solution) code, so, before, they asked about how many lines of code contains our project.
一个团队会分析我们的.NET项目(解决方案)代码,所以,之前,他们问我们的项目有多少行代码。
Is there some statistical data, some code metrics in VS 2010?
VS 2010 中是否有一些统计数据、一些代码指标?
回答by serhio
Open the search (ctrl+shift+f),
打开搜索 ( ctrl+ shift+ f),
Search for all files in the solution (*.cs or *.vb), use regular expression ^(line beginning).
搜索解决方案中的所有文件(*.cs 或 *.vb),使用正则表达式^(行首)。
Wait.
等待。
回答by Nick Martyshchenko
You can also use DPack:
您还可以使用DPack:
DPack is a FREE collection of Microsoft Visual Studio 2008/2010 tools. DPack is designed to greatly increase developer's productivity, automate repetitive processes and expand upon some of Microsoft Visual Studio features.
DPack 是 Microsoft Visual Studio 2008/2010 工具的免费集合。DPack 旨在极大地提高开发人员的工作效率、自动化重复流程并扩展 Microsoft Visual Studio 的一些功能。
DPack is very handy but you can use it only for solution statistics:
DPack 非常方便,但您只能将它用于解决方案统计:
Solution statistics feature allows one to evaluate the size of the entire solution. It collects information on all projects in the currently opened solution. The information is collected on code files only and includes: total number of lines, total number of code lines, total number of comment lines and total number of empty lines in each project. Solution statistics can be exported to a comma delimited CSV file using Export button.
解决方案统计功能允许评估整个解决方案的大小。它收集有关当前打开的解决方案中所有项目的信息。该信息仅针对代码文件收集,包括:每个项目中的总行数、总代码行数、总注释行数和总空行数。可以使用“导出”按钮将解决方案统计信息导出到逗号分隔的 CSV 文件。
回答by Nabil Sham
Using powershell move to the folder containing your project files and enter the command
使用 powershell 移动到包含项目文件的文件夹并输入命令
(dir -r -include *.cs,*.vb | select-string . ).count
replace "cs" "vb" with file extensions you want to include in your count.
用您想要包含在计数中的文件扩展名替换“cs”“vb”。
回答by Alois Cochard
Yes
是的
Here is a tutorial: http://blogs.msdn.com/b/habibh/archive/2009/10/27/how-to-count-the-lines-of-code-loc-in-your-application-using-visual-studio.aspx
这是一个教程:http: //blogs.msdn.com/b/habibh/archive/2009/10/27/how-to-count-the-lines-of-code-loc-in-your-application-using -visual-studio.aspx
Or you can use a dedicated tools like this one: http://code.msdn.microsoft.com/LOCCounter
或者您可以使用这样的专用工具:http: //code.msdn.microsoft.com/LOCCounter

