Exclude test projects from Ndepend Analysis - ndepend

I have a visual studio solution which has a lot of projects including unit test projects. I am using NDepend API to analyze the solution. The intention is to get the relationship between methods. I am doing this by using MethodsCalled and MethodsCallingMe. Since there are test projects in the solution. I am ending up with lot many relationships as the unit testcases call the actual implementation, which is unnecessary for what I am trying to achieve.
Is there a way to exclude unit test projects when analyzing the solution?
Ndepend - exclude assembly in some ways but not others
The link has some information not sure if this can be used with NDepend API.
Any help appreciated.

Are you getting your assemblies through this code?
// 2) obtains assemblies file path to analyze
var assembliesFilePath = (from vsSlnOrProjFilePath in vsSlnOrProjFilePaths
from assembliesFilePathTmp in visualStudioManager.GetAssembliesFromVisualStudioSolutionOrProject(vsSlnOrProjFilePath)
select assembliesFilePathTmp).Distinct().ToArray();
What about a LINQ filtering by assembly name, something like:
visualStudioManager.GetAssembliesFromVisualStudioSolutionOrProject(vsSlnOrProjFilePath)
.Where(a => !a.Name.ToLower().Contains("test"))

Related

nDepend - get filtered assemblies to analyze

I am using nDepend and I wonder how can I tell nDepend that I'd like to analyze assemblies which names start with specfiic string (Test for example). What I see is that I need to provide full names of the assemblies and I cannot use any sort of wildcards.
Have you tried this?
NDepend Start Page
Analyze VS Solutions and VS Projects
Select a VS solution file
then on the up-right corner of the DataGridView use the filter capabilities (shown in screenshot below)

asp.net decompiled function is same but ndepend shows difference

I have decompiled 2 .net 2.0 dlls (using a decompiler tool) and when I compare a function both are same. But when I compare these 2 assemblies, ndepend shows difference in ILInstructions and NBLinesOfCode.
Please let me know why ndepend is showing the function difference but decompiled code is same? if having differences (IL Instructions and LOC) in ndepend means the functionality is really different for 2 dlls?
What steps I can take to make the 2 assemblies same so that ndepend doesn't show difference in that function?
Please note I have lost original source code and I am trying to re-build the source code to make it original dll.

Comparing two dotCover coverage reports to find intersection?

I've got a bunch of C# code that's covered by both unit tests and system tests. I'd like to find those parts of the code that are covered by both, by only the unit tests and by only the system tests.
I've can generate coverage reports for the two sets (unit tests vs system tests) by using JetBrains dotCover.
How do I compare these two coverage reports?
I've got NDepend, if that helps.
Roger, with NDepend you can still import several DotCover coverage xml files (with the right DotCover XML for NDepend setting).
I'd like to find those parts of the code that are covered by both
Use the Merge Option AND as shown on the screenshot below. This will help, it will tell you which method are covered by both tests sets.
If you need to zoom at line by line level covered by both tests sets, unless NCover has tooling for that, you'll need to programatically do the merge of the two coverage files by yourself (it should be not that hard).

How do you query .Net source for methods containing a string using NDepend?

I would like to find out all classes that have an inline SQL Statement in them. How do you write an NDepend CQL query that scans the method body looking for the use of say "Select"? Is it possible?
Thanks in Advance.
NDepend is more about code structure, code quality, code metrics, code diff ... It doesn't know about string constants content, so this is not the right tool for what you need to do.
For that I'd advise using Mono.Cecil which is an assembly content reader API (OSS/free) pretty well done! Btw NDepend relies on Cecil for reading assemblies and I can say it is a great API with high performances and pretty close to bug free!.

nCover With many class libraries

So I have my project and it is set up like this:
MyProject
MyProject.Module1
MyProject.Module1.Tests
MyProject.Module2
MyProject.Module2.Tests
What I want is the code coverage number for the entire project.
I am using nCover... what is the best way to do this? For example would I have to rearrange the project and have everything put into MyProject.Tests?
It depends on how you're testing. Most test frameworks will let you run tests for multiple assemblies as separate arguments. If you can't run them all together, you can always use NCover's merge feature. Check out http://docs.ncover.com/ref/2-0/ncoverexplorer-console/merging-coverage-data/.