4

I have a very big EF edmx model with over 450 classes/entities. This has grown organically over the last 5 years. With Visual Studio 2013 and the CodeLens feature I have noticed that some classes have 0 references listed. When I do some research I have found that this is true and I can remove that entity from the model.

The problem is that I would have to look at all 450 classes in the edmx to see if CodeLens says there are 0 references. Is there any report, export that I can get with CodeLens? Is there any way to extend it to provide this if there is no report?

Scott Wylie
  • 4,725
  • 2
  • 36
  • 48
  • codelens is really only running on the editor windows you have open, so there are definitely better ways. – John Gardner Feb 04 '14 at 22:41
  • CodeLens gives us statistics about individual code elements within a project but does not gives us any chance to analyze these statistics. It would indeed be a great thing if we could get a bigger picture on this data, especially that this tool ships in with Visual Studio. – Ucodia Sep 23 '14 at 09:54
  • CodeLens is not really designed for this. Please see [this answer on SO](http://stackoverflow.com/questions/30974433/get-list-of-zero-reference-codes-in-visual-studio/37579734#37579734) show you how to search your project for dead code using the built-in code analysis tool. – Adam White Sep 01 '16 at 07:17
  • @AdamWhite I responded to that answer a few months ago with a comment that it does not entirely work. If you have large solution with public methods, CodeLens will tell you they are not used, there is just no way to output those results or so it solution wide. – Scott Wylie Sep 01 '16 at 16:31

1 Answers1

4

Is CodeLenses requirement? I found several things that can help you:

  • Code analysis
  • NDepend
  • Resharper

Here are some links: - http://blogs.msdn.com/b/habibh/archive/2009/07/31/discover-dead-code-in-your-application-using-code-analysis.aspx - Find unused classes in a .net project - https://stackoverflow.com/questions/1413548/visual-studio-find-unused-code

Community
  • 1
  • 1
vmg
  • 9,920
  • 13
  • 61
  • 90