How do I show how many lines of code my project contains in Visual Studio? [duplicate]

北战南征 提交于 2019-11-29 18:57:51

Code Metrics is only available in the Team System versions of Visual Studio 2008. If you have an Express Edition, Standard, or Professional you're out of luck.

See comments and screenshots here:

Lei

You don't need 3rd party tools, just press CTRL+SHIFT+F, and in the window that pops up choose "use regular expression". Use this Regular Expression:

^:b*[^:b#/]+.*$

For Visual Studio 2012 and above the regular expression is:

^(?([^\r\n])\s)*[^\s+?/]+[^\n]*$

DPack does this. After installing, just go to Tools -> DPack -> Solution Statistics...

http://www.usysware.com/dpack/

I don't have that feature in my VS2008, so a few months ago I implemented a quick and dirty windows app that counts the number of CRLFs in my C# files. Granted, this counts empty lines, and lines in files generated by VS, but with a bit of tweaking, I am sure you could make it generate a good count. Here is the operative code in the Windows Form; the dlgFolder control is the FolderBrowserDialog control:

if (dlgFolder.ShowDialog() == DialogResult.OK)
{
   int totalLines = 0;
   string[] fileList = Directory.GetFiles(dlgFolder.SelectedPath, "*.cs",    SearchOption.AllDirectories);

   for (int x = 0; x < fileList.Length; x++)
   {
      string[] sourceCodeLines = File.ReadAllLines(fileList[x]);
      totalLines += sourceCodeLines.Length;    
   }

   MessageBox.Show(String.Format("There are {0} lines of C# code in the folder{1}",
totalLines.ToString(), dlgFolder.SelectedPath));
}

find . -type f -print0 | wc --files0-from=-

oops! you're on windows...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!